Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Automate Your Form Validation

Because data validation is often a repetitive process, you can write generic validation and formatting rules as long as you send values to the validation functions rather than trying to reference named controls.


advertisement
orm validation is a checking process that occurs between the time the user clicks the submit button and the actual submission of the form. In this article, you'll see how to intercept the submission and pass the form data through one or more validation tests. If the data passes the tests (i.e. the validator returns true), the code formats the data and then submits the form. If the form data fails any validation test, users see a prompt asking them to complete the form correctly. Form validation involves string manipulation primarily, so a single script serves all three major browser types: Internet Explorer 4+, Netscape Navigator 4x, and Netscape 6.The examples in this remainder of this article implement rules for common validation tasks. They break down naturally into five sections: the HTML form, the support functions, the validation rules, the formatting functions, and the validation routine.

Validating forms on the client lightens the load on the server and allows you to format data before it is sent for processing. Unfortunately, writing client-side validation scripts is a tedious and error-prone process. You can improve your development time and reduce errors by creating generic reusable validation scripts. The problem is: How can you write generic validation functions that work with different form content on the client?

The key to client-side validation is to intercept form submission and validate your data before submitting it for further processing. Because data validation is often a repetitive process, you can write generic validation and formatting rules as long as you send values to the validation functions rather than trying to reference named controls.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date