You need a custom function that you can later connect to the form.For more information about creating a function, see JScript Functions.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 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.
For more information about HTML and Web scripting, see one or more of the following references.
However, client-side validation may not work in all instances.
A user may have a browser that doesn't support client-side scripting or may have scripting disabled in the browser.
Because the code is stored within the page or within a linked file, it is downloaded into the browser when a user accesses the page and, therefore, doesn't require a roundtrip to the server.
For this reason, client form validation can be faster than server-side validation.