When referring to Java Script in general, this article uses the generally accepted term "Java Script." However, when referring to documentation on the Microsoft Developer Network (MSDN) Web site, this article uses the term "JScript." Note The previous code specifies an e-mail address for the Action attribute of the form property.

For more information, see ACTION Attribute | action Property and form property.

validating when the user submits the form-1

The action attribute tells the browser what to do when a user submits the form.

If you want to test this form, change this e-mail address to your own e-mail address.

In this table, Element refers to the name of the HTML element for the form field, Type refers to the value of the type attribute for the form field, and Label refers to the text to the left of the form field. Form code updated with name attribute values Now that you have assigned names for the form and form fields, you are ready to start writing the script that handles the validation for the fields. If you are typing the Java Script code in this article manually and receive errors, you should check that all casing is the same as shown in this article.

Otherwise, you may want to review JScript Run-Time and Syntax errors.

The validation script in this article returns a Boolean value that specifies whether the data contained in the form is valid. Variables are not required, but they make accessing each field easier.

To create your own custom function, insert a SCRIPT element into the HEAD section of your form page; within the SCRIPT element, use the function statement to insert a function named Validate Contact Form. This code should look something like the following code sample. Starting script function To access the form fields within the code, you should create variables. For example, without a variable, you would have to type document. Name every time you needed to access the Name field.Sending data back and forth between the client and server can cause some delays.However, for some form functions, server-side validation is necessary.A function is a piece of code that consists of one or more lines of script.A function can take arguments and can return values.In order to access your form fields in code, you need to assign names to the form and each of the fields. For more information see, NAME Attribute | name Property.