3 Replies Latest reply: May 23, 2013 11:13 AM by GKaiseril RSS

    Show/Hide Form Fields

    lmphil Community Member

      Thanks in advance for your help. I am working with a form that contains calculated fields. The calculated field is formatted for currency, so it contains the "$ 0.00" in the field automatically. Customers may also print out this form and fill it in by hand, so the "$ 0.00" is a nuisance. Is there any way that I can hide the calculated field unless the user actually enters data in the fields to be calculated? Any advice would be appreciated. Thanks.

        • 1. Re: Show/Hide Form Fields
          GKaiseril CommunityMVP

          The us of the currency symbol does not allow the suppression of the zero display with a null string. So you can either set the fields not use the currency symbol or dynamically change the field format with JavaScript.

           

          For the validation script use the following code:

           

          // custom validation code;

          var cCurrency = ""; // clear currency symbol;

          if(event.value != 0) {

          event.value = event.value;

          // set currency symbol to USD

          cCurrency = "$";

          } else {

          // zero value set field value to the null

          event.value = "";

          }

          // set field format with/without currency symbol;

          AFNumber_Format(2, 0, 0, "", cCurrency, true);

          // end custom validation code;

           

          The number of decimal places is assumed to be 2.

           

          The form will need to be cleared or a calculation performed so the calculated fields will be updated and the validation script will run before one will see the results of this change.

          • 2. Re: Show/Hide Form Fields
            lmphil Community Member

            Thanks! Does that also work in the case of a "%"?

            • 3. Re: Show/Hide Form Fields
              GKaiseril CommunityMVP

              One would need to use the AFPercent_Format with the correct parameters.

               

              AFNumberFormat help