6 Replies Latest reply on May 27, 2011 6:33 AM by wcendro1

    Validating a field has content before allowing user to move to next field

    wcendro1

      I posted the discussion for completing the validation before printing and as I thought about it more last night, I needed to change it because I do need to allow for our branches to print blanks of the form for certain situations.

       

      Before pursuing the validation before printing, I was trying to display an error message if a required field was left blank before moving to the next field.  I have tried the following scripts:

       

      #1

      if(!event.target.valueAsString) {

          app.alert("This field must be complete. Please enter the Customer's Name", 3);

      }

      This script worked as I used it with 'On Blur', but after displaying the error message it went to the next field.  Then trying to back to the name field, threw up the error message for the next field (I have several fields in a row that are required).

       

      #2

      f=getField(event.target.name)

      if(f.value.length==0)

           {

           f.setFocus()

          app.alert("This field must be complete. Please enter the Customer's Name")

           }

      I was using this with the 'On Blur' also, but I was getting into a loop in which the error message would not go away, and I have to kill the application.

       

      #3

      if(event.value.length<2)
          {
          //Sample Message

           app.alert("This field must contain 9 digits.")
          event.rc=false;
          }

      I was trying this script with the validate function.  It will not work with any value less than 2.

       

      As I mentioned before, I am new at scripting, so any help would be greatly appreciated.