If your form has required fields, but you don’t know which fields are required until checking the data in other fields, you can’t just rely on a single list of required fields. For example, if you have a pull-down list of employee or student, you might need to check the value of that pull-down list before you know which fields are required.
Override the default form verifier
Getting field values
You can use the function “fieldValue” to get the value of a field. Give it the form and the name of the field, for example, “fieldValue(theForm, "Department")”.
Verifying a list of fields
You can use the function “verifyFields” to verify that a field or list of fields contain something. This function assumes that any field in the given list must contain something; if you’ve specified that one or more of the fields must be numeric or match some other criteria, it will also verify that as well. It does not verify any fields except the ones you give it.
The verifyFields function returns a message that can be displayed via “alert” if any of the fields do not verify.
If the status form field is “employee”, the function sets an array containing department and hire date. Otherwise, the function sets an array containing major and graduation year. It then calls verifyFields with that array. If any messages come back, it displays the message and returns false, blocking form submission.
Otherwise, it returns true and lets form submission continue.
Pass to the normal verify function
If you want to run the normal verification script, use “verifyForm”. For example:
That runs the normal verification after running the custom verification. If any error messages come back from the verifyFields function, the custom myVerify returns false, and the form is not submitted. If there are no error messages from the custom verification, the custom myVerify returns whatever the standard verifyForm returns.