2 Replies Latest reply on Jan 26, 2018 12:58 AM by jlggps

    Conditional calculation script in field that allows input if conditions not met

    jlggps Level 1



      I am new to the group and to JavaScript and I am trying to create a calculation script on a field that if two conditions are not met, the field allows the user to enter data manually.


      In the script below, the calculation is performed if a value is entered in Field1 but I'd like it to allow the user to manually enter data into the field if no data is entered in Field1 and Field2 (and no calculation is performed).  I hope my question makes sense...  Sometimes there is no value for Field2 so the user must be able to populate the field.  Even an override would work that if the user enters a value into the field, the calculation script is ignored.


      // Get first field value (Condition one)

           var f1 = getField("Field1").valueAsString;


      // Get second field value (Condition two)

           var f2 = getField("Field2").valueAsString;


      // Get Third field value

           var f3 = getField("Field3").valueAsString;


      if (f1.length>0) {

      // Set this field value equal to the sum in inches

          event.value = (Number(Number(f1)+Number(f3)) * 12).toFixed(2);


      else {

          event.value = ""; 



      Thank you,



      Acrobat Standard 2017 (Windows)