Form validation through jQuery
















         Often we use forms in all web pages. Forms takes the data from the user and then sents it into particular pages for action. But what is the proof that the sent data is correct or if the user has mistyped information in fields. In that case, form validation is used in order to validate the data which has been entered. We can validate the data either in server side after submitting or in client side after entering the data. Here client side validation will be good as the client can make changes soon.
         Validating  the form using jQuery is simple. As user will enter the data in fields it will be validated, so no need of refreshing the page, success and error reports will be shown as we enter the data.
         Here  jquery.validate.js is the file which is developed by the jQuery development team which contains all the codes which will handle the form and fields. So it will be easy as plug and play if provide necessary data in the script. Just before validating the form we have to include the .js library file and jquery.validate.js file.
           Lets have a look of an example form








       Here in the above example 4 fields are there and the minimum length is 5 default. As the user enters the name in "name field" and moves to next tab, as it looses its focus it checks the length and if it is less then it displays the error message or else displays as valid. In the same way validation is carried out for each field. In the confirm password, it rechecks the entered value with the previous password field. If all the data entered in the form is correct then it submits the form calling the form.submit() function.