2 Replies Latest reply on Apr 22, 2014 1:40 PM by IDOTRhonda

    Do not display 0.0% as answer in calculated field

    IDOTRhonda

      My field is formated to % and one decimal place and it shows 0.0%.  I would prefer it be blank until both fields are filled in that produce the answer.  I tried to do that with the following calculation and it works until I changed the format to percentage. 

       

      var v1 = +getField("Tons UsedRow1").value;

      var v2 = +getField("Tons RequiredRow1").value;

      if (v1 !== 0 && v2 !==0){

      var result =(v1 / v2);

      event.value = result;

      }else {event.value = '';}

        • 1. Re: Do not display 0.0% as answer in calculated field
          gkaiseril MVP & Adobe Community Professional

          Only a numeric formatted field with nor currency symbol or percentage symbol and display a null value.

           

          You need to use the built-in formatting functions of Acrobat JS to set the field format as needed.

           

          I would start with the field being formatted to "None"

           

          User you custom calculation script.

           

          Add a custom validation script:

           

          var nDec = 1; // set the number of decimal places; // number & percent;

          var sepStyle = 0; // thousand separator style; // number & percent;

          var negStyle = 0; // negative style; // number only;

          var currStyle =""; // always null; // number only;

          var strCurrency = ""; // currency symbol; // number only;

          var bCurrencyPrepend = false; // currency prepend; // number only;

          var bPercentPrepend = false; // percentage prepend; // percent only;

          if(event.value == 0 || event.value == "") {

          event.value = "";

          AFNumber_Format(nDec, sepStyle, negStyle, currStyle, strCurrency, bCurrencyPrepend);

          } else {

          AFPercent_Format(nDec, sepStyle, bPercentPrepend);

          }

          1 person found this helpful
          • 2. Re: Do not display 0.0% as answer in calculated field
            IDOTRhonda Level 1

            This is perfect! Thank you very much