Thursday 29 December 2011

jQuery Validator

In this article we will see how to create validation framework in jQuery. I tried to do create validator similar to ASP.NET.

Let's see how we can do this.



Step 1: Place two textboxes (First Name and Last Name) which will accept only alphabet, a dropdownlist, another textbox (Age) whic will accept only integers, another textbox (Address) which will accept alphanumeric dharacters.
All are mandatory except address field. Different type of validation is required in different textboxes.

First Name *
Last Name *
Gender *






Age *
Address




Step 2: Place below style in the header section of the page. There are few style which doesn't have and style property in it. It will be used to decide which validation need to be performed on any field.



Step 3: Add jquery reference in the header section of the page.



Step 4: Place below javascript in the page to execute validation on the contols.



Live Demo
Like us if you find this post useful. Thanks!

Download Code

No comments:

Post a Comment