2 Replies Latest reply on Apr 26, 2016 7:40 AM by madeleinel22391508

    If statement before correcting for percentage

    madeleinel22391508 Level 1



      I have a field (SCharge1) in which clients specify the sales charge (0-3%) applied. I would like to check to make sure that the amount entered is between 0 and 3 however, I have modified the percentage format as to divide the amount entered by 100 so that clients can enter 1 and it equals 1% so that clients do not get confused when filling out the form. I have done this by running a custom validation script:


      if (event.value !== "") {

      event.value = event.value / 100 ;



      I was wondering if there was a way to check to make sure the field is between 0-3 and if not creating an error message to modify the field?  I am unsure whether to run the check before or after the validation script and whether to combine the scripts or add a separate option. This is what I tried to check the sales charge after but to no avail:


      (function () {



          var v = getField("SCharge1");


         if(v >0.03){

         var resp = app.alert({cMsg: "Fund Code does not match the Fund Class selected, please revise.", nIcon:0});




      Any help would be much appreciated!

        • 1. Re: If statement before correcting for percentage
          gkaiseril MVP & Adobe Community Professional

          I suggest you take advantage of the built-in format for "Percentage". It will properly display the percentage but keep the value of the field as a decimal number and that value can be used in any calculation without any adjustment for a shifted decimal place.


          There is a "Validation" tab which can be used to check the entered value or you can use a custom keystroke script to validate that the entered data in numeric values only and the range of the entered value. You will need to use the willCommit property to for checks that are done before the field is committed and after the field is committed.

          • 2. Re: If statement before correcting for percentage
            madeleinel22391508 Level 1

            Unfortunately, although strange I don't want it displayed as the percentage format does.  The percentage format shows the value as a decimal which although is the true value ie. 1 % is 0.1, it is a client based form and entering 1 and then having it change to a decimal would be confusing even though technically that is its value. That is why I have the event value at the beginning. Would it be possible to leave the decimal as you suggested and then have the format change (dividing the value by 100) after the numeric check has occurred?