Form Validation : more features
This is in continuation of the JavaScript Form Validation script explained here.
In this page, we will see some of the advanced features of the script.
Showing all the form validation errors together in a message box
For some forms, you may wish to show all the errors together.
You can do that just by adding a function call, if you are using the
JavaScript form validation script.
If you want to show all the error messages together in the message box,
then just call the EnableMsgsTogether() function in the validator object.
For example:
frmvalidator.EnableMsgsTogether();
See the form validation sample code
Showing the form validation errors on the page itself
You can display the validation errors on the page itself.
For this,there are two steps that you need to do.
- Create a place on the page for displaying the errors
create a DIV on the page for the errors the DIV should be named as
{formname}_errorloc where {formname} is the name of your form.
For example:
<div id='myform_errorloc' class='error_strings'></div>
- Enable on-page error display
Call the EnableOnPageErrorDisplaySingleBox() function to enable
on page error display.
For example:
frmvalidator.EnableOnPageErrorDisplaySingleBox();
frmvalidator.EnableMsgsTogether();
See the form validation sample code
that illustrates the on page error display.
|