If an HTML document contains more than one forms, they can be accessed as either by document.form_name where form_name is the value of the name attribute of the form element or by document.forms[i] where i is 0, 1,2,3....

and document.forms[0] refers to the first form of the document, document.forms[1] refers to the second form of the document and so on.

Now we will see how we can validate our entered form data before submitting it to the web server.

The following example shows how to validate an entered email address.

You can do and impressive amount of form validation with just HTML attributes.

You can make the user experience pretty clean and clear with CSS selectors.

In the above form, we are calling validate() to validate data when onsubmit event is occurring.

The following code shows the implementation of this validate() function.

is the external Java Script file which contains the Java Script ocde used to validate the form. Notice that for validation, the Java Script function containing the code to validate is called on the on Submit event of the form. Flowchart : Here is the entire Java Script used for validation of the form.

For the sake of demonstration, we have taken five countries only. function form Validation() function userid_validation(uid,mx,my) function passid_validation(passid,mx,my) function all Letter(uname) function alphanumeric(uadd) function countryselect(ucountry) function allnumeric(uzip) function Validate Email(uemail) function validsex(umsex,ufsex) Flowchart : Download the Validation code from here.

Form validation is the process of making sure that data supplied by the user using a form, meets the criteria set for collecting data from the user.