2 Replies Latest reply on Jan 3, 2018 7:44 AM by gkaiseril

    Check combo for "empty" fields

    jenniferc11972072

      Currently working on a script for the verify empty fields before printing to give a warning.

       

      what i purloined and modified from the forum was

       

      // check for empty fields

      var emptyFields = [];

      for (var i=0; i<this.numFields; i++) {

           var f= this.getField(this.getNthFieldName(i));

           if (f.type!="button" && f.required ) {

                if ((f.type=="text" && (f.value=="" || f.value==" ")) || (f.type=="checkbox" && f.value=="Off")) emptyFields.push(f.name);

      }

      }

      if (emptyFields.length>0) {

           app.alert("Important - You must fill in the following fields or your reimburstment will be delayed:\n" + emptyFields.join("\n"));

      } else this.print();

       

       

      I need to add for it to check combo boxes for the answer "-" as that the default setting or empty setting.  Is that possible?

        • 1. Re: Check combo for "empty" fields
          try67 MVP & Adobe Community Professional

          Change this part:

          if ((f.type=="text" && (f.value=="" || f.value==" ")) || (f.type=="checkbox" && f.value=="Off"))

          To:

          if (f.valueAsString==f.defaultValue)

          1 person found this helpful
          • 2. Re: Check combo for "empty" fields
            gkaiseril MVP & Adobe Community Professional

            One can also use the "defautlValue" property of a field to check for an uncompleted field.

             

            // check for empty fields

            var emptyFields = [];

            for (var i=0; i<this.numFields; i++) {

                 var f= this.getField(this.getNthFieldName(i));

                 if (f.type!="button" && f.required ) {

                      if ((f.defaultValue) emptyFields.push(f.name);

            }

            }

            if (emptyFields.length>0) {

                 app.alert("Important - You must fill in the following fields or your reimburstment will be delayed:\n" + emptyFields.join("\n"));

            } else this.print();

             

            You may have to adjust your code if there is a signature field.

            1 person found this helpful