Tuesday, May 7, 2013

Required Field Validation in jQuery

I have told before also that with jQuery we can do all those tasks that we use to do using javascript. Most of the time we need to validate different fields for particular set of input like email validation, passwords, username etc.

All the fields have different set of inputs but needs to be validated for correct set of input. We prefer doing this on client side instead at server side. So, for doing so at client side we have javascript and now jQuery.

Here in this article we will discuss required field validation using jQuery That is, we will validate those fields where some input is necessary like username, password, email address, Ph No etc. We are taking a simple example of user login where we have two fields username and password and both the fields are necessary to be filled before doing submission. As soon as user clicks Submit button the fields will be validated for some input.

Following is the logging form named login.html. Try it out.

Username
Password

ShowCode/HideCode