I have a form that has required questions on it. Before the user submits the form, they need to fill them all out. Is there a way, if they haven't filled out the correct questions, when they click on the submit button, that a box will pop up that will tell them which questions they missed?
Thanks in advance!
Views
Replies
Total Likes
A common technique is to hide the submit button (set presence to 'hidden'), add a second button labeled 'Submit' that does form validation on the click event, and call the click event on the 'real' submit button if validation is successful.
Here is a simple example where I validate two fields. If both fields are not null I call the click event on object 'submitBtn'.
// form1.page1.subform1.callSubmitBtn::click - (JavaScript, client)
if (form1.page1.subform1.firstName.isNull || form1.page1.subform1.lastName.isNull) {
xfa.host.messageBox("First name and last name are required fields.");
}
else {
form1.page1.subform1.submitBtn.execEvent("click");
}
Steve
Is there a way to do this without having to type in all the field names? My form is over 5 pages long with around 100 different fields. Some of the fields are also only mandatory if the user checks a previous field.
Thanks!
Views
Replies
Total Likes
At the field level you could set the text field type to 'User Entered - Required' to capture null fields. When the submit executes null fields will be highlighted.
For compound validations where there are field dependencies you will have to write script and specify field names. The pain you experience scripting field names is dependent upon your form structure and naming conventions. If field names are globally unique you will have less pain - you can reference the abbreviated name. If field names are not globally unique you will have more pain - you will have to fully-qualify the field references.
Steve
Views
Replies
Total Likes
The problems I'm having with having the fields just set to required is:
Views
Replies
Total Likes
You may want to take a look at John Brinkman's validation scripts and exclusion group scripts:
http://blogs.adobe.com/formfeed/2008/12/exclusion_groups_v40.html
It's worth reading the whole series of posts (parts 1-3).
Latest version of the script objects are in this post (as far as I know):
http://blogs.adobe.com/formfeed/2009/03/a_form_to_design_a_form.html
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies