Sample Form Error Handling Examples
- → Attach Validation to the Form
- → Attach Validation to the Controls
-
Flag Customization:
→ Attach Validation Without Flags - → Attach Validation Custom Flag
Attach Validation to the Controls
This approach attaches the validation initiation call to each form control. This method should only be used if for any reason, the form should not globally initiate the validation script - i.e. the form has multiple parts, each requiring separate validation.- This approach only validates the controls onChange. No validation is done onSubmit
- Some extra code in the form submission event handler will be needed if onSubmit validation is to be carried out.
Please use the following public method of the validation object on form submit when the validation is not attached to the form as in the above example.
@param:onSubmit - Specifies whether this status check is being request on the submission of a form. Set this to true
@param:form - Specifies the form as a jQuery element
$.validator.validateForm.attempt(onSubmit, form);Click on this button to simulate a form submission with validation check: