5 Replies Latest reply on Jan 26, 2016 1:28 AM by try67

    Field Validation Upon Submission

    miss-charlotte Level 1

      I have a form with a couple Required Fields that have required formatting scripts included.

       

      For instance, I have a field for an email address with a script that gives them an error if a valid address is not inserted. I also have a field for a phone number where they need follow a specific format. If they do not, they get a warning.

       

      However, they can choose to ignore the warnings that appear when they enter incorrect information and carry on to the next fields in the form.

       

      My question is... how can I ensure that the form will not be submitted UNLESS they correctly fill out the 2 fields mentioned above?

       

      As it is now, the form will submit regardless of what they include in the fields.

       

      Do I need to program the specific fields in question to absolutely reject anything that is incorrect?

       

      Thank you,

        • 1. Re: Field Validation Upon Submission
          try67 MVP & Adobe Community Professional

          Do I need to program the specific fields in question to absolutely reject anything that is incorrect?

          Yes.

          • 2. Re: Field Validation Upon Submission
            miss-charlotte Level 1

            Thank you. What kind of a script would I need?

            • 3. Re: Field Validation Upon Submission
              try67 MVP & Adobe Community Professional

              A custom validation script that examines the input (event.value) and accepts or rejects it by setting event.rc to true or false, respectively.

              • 4. Re: Field Validation Upon Submission
                miss-charlotte Level 1

                Thank you. Some background: this is a required field and not only does the client want the default red frame around the field, but they want text ("REQUIRED FIELD") to appear in this field and then disappear when user clicks into the filed. I've had success with the following for this field (and I realize this may not be best way to go about this):

                 

                UNDER OPTIONS, IN THE DEFAULT VALUE BOX I HAVE THIS TEXT:

                REQUIRED FIELD

                 

                 

                THEN I HAVE THE FOLLOWING IN THE ACTIONS:

                 

                ON FOCUS Script:

                if (event.target.value==event.target.defaultValue) event.target.value = "";

                 

                ON BLUR Script:

                if (event.target.value=="") event.target.value=event.target.defaultValue;

                 

                ON BLUR Script:

                var email = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/; if (event.value!=""){if (!email.test(event.value)){event.rc = false;app.alert("\"" + event.value + "\" is not a valid email address.");};};

                 

                 

                Now the final task is a Validation Script to get the field to reject anything that does meet the above format. As it is now they get a warning but they can still ignore and move on to the next fields. I've been trying different things but don't know enough about javascript and time is getting tight.  I may try to find someone to hire to do this.

                • 5. Re: Field Validation Upon Submission
                  try67 MVP & Adobe Community Professional

                  You have to put the validation script under the validation event, not on the on blur event.

                  Also, if you're using a default value as the instructions text you have to explicitly allow for it your validation script (since it's not a valid email address).