Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Field Validation Upon Submission

Contributor ,
Jan 22, 2016 Jan 22, 2016

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,

TOPICS
Acrobat SDK and JavaScript
832
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 23, 2016 Jan 23, 2016

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

Yes.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jan 23, 2016 Jan 23, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 23, 2016 Jan 23, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jan 25, 2016 Jan 25, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 26, 2016 Jan 26, 2016
LATEST

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).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines