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.

form validation message box

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.

form validation: on page error

For this,there are two steps that you need to do.
  1. Create a place on the page for displaying the errors

  2. 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>

  3. Enable on-page error display

  4. 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.

  • Digg
  • del.icio.us
  • Netscape
  • Reddit
  • StumbleUpon
  • Technorati
  • YahooMyWeb

HTML Forms
HTML Form Tutorial
The Form Tag
The Form Submit Button
Form design software

Javascript Form Handling
  Basics
Using getElementById to get the elements in a form
Set value of form element using JavaScript
Get value of form element using JavaScript
Handling multiple forms using JavaScript
JavaScript reset/clear a form
  Advanced
JavaScript Form Validation
Submitting a form using JavaScript
Can JavaScript Email a Form?
Switching the form action field dynamically
JavaScript Button

JavaScript Popup Windows
The window.open method
The window.close method
More ...

 
.   Copyright © 2003-2008 Simfatic Solutions. All rights reserved.