These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Required field not validating properly (validation error message not appearing)

SLDC
Registered: Oct 25 2010
Posts: 70
Answered

I've got a form with an email address field (using the standard Designer custom object) that is set to "User Entered - Required".
 
When I tested an early version of the form, this worked as expected. If the field was left blank, the required-field-empty error message appeared and the triggering event was prevented.
 
At some point, something I did broke the standard operation. While the field still appears with a red border to indicate that it's required, there's no message about the field being empty and the triggering event proceeds as though there's no problem. In this case, I get an email with my attached PDF and a recipient address of "null".
 
I haven't added any code to the Designer email field or removed any of the standard code.
 
Since I can't figure out what could possibly be causing this problem, my workaround is for my triggering event (a button click) to test the email field's value and provide an app.alert message if the email field is empty. The email with attached PDF still starts, though; this requires the user to pay attention to the app.alert, cancel their email, and go back to fill in the address. Not optimal.
 
Has anyone got an idea what could prevent a field marked Required from operating properly? Thanks.
 
SLDC

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The null test. Look in the XML for the form to see how the null test is set.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

SLDC
Registered: Oct 25 2010
Posts: 70
thomp wrote:
The null test. Look in the XML for the form to see how the null test is set.
The source shows:

<validate nullTest="error"/>
which should be correct, I think.

It's followed by the Designer email address object validation code, reproduced below... but even if I take that out, and leave it as a text field with no scripted events, the null test still shows 'error', and yet the field isn't treated as required at run time.

// Validate the email address. var r = new RegExp("^[A-Za-z0-9_\\-\\.]+\\@[A-Za-z0-9_\\-\\.]+\\.[a-z]{2,3}$"); // Create a new Regular Expression Object.// Set the regular expression to look for  an email address in general form. var result = r.test(this.rawValue); // Test the rawValue of the current object to see// if it fits the general form of an email address. if (result == true) // If it fits the general form,true;			// all is well.else				// Otherwise,false;			// fail the validation.
SLDC
Registered: Oct 25 2010
Posts: 70
Accepted Answer
I've figured out the problem - custom buttons using event.target.submitForm don't seem to respect the "mandatory" property the way that the default Designer submit-by-email button does (or a custom button using Submit functionality).

I've set the click event on my custom button to use event.target.submitForm only if the required field != null, and the else statement sets mandatoryMessage on that required field. It's working now.

Thanks for the help.