Validating a form Meet and fuck free trial
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.In addition, this article assumes a general understanding of HTML and Java Script, although a thorough understanding is not required.For more information about HTML and Web scripting, see one or more of the following references.
Both Java Script and JScript are ECMAScript-compliant languages.
(16 printed pages) Introduction Getting Started Writing the Validation Script Connecting the Form to the Script Associating Form Fields with Custom Script Code Listing Conclusion When you create forms, providing form validation is useful to ensure that your customers enter valid and complete data.
For example, you may want to ensure that someone inserts a valid e-mail address into a text box, or perhaps you want to ensure that someone fills in certain fields.
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.
You may assign any name you want that is composed of alphanumeric characters (without spaces), but to make writing the code easiest, you should provide a useful, friendly name for each of the fields.