jQuery Validation Plugin

Demo:

Registration

Usage:

Wrap all required fields in .required-field class (can be a div, a span, a p or any element) and apply the validation function to the form

$("#myform").submit(function () {
return $(this).validation(); //returns true or false
});

Demo HTML:

<form action="" method="post" id="myform"> 
<fieldset>
<legend>Registration</legend>
<div class="required-field">
<label for="firstname">First Name</label>
<input type="text" name="firstname" id="firstname" />
</div>
<div class="required-field">
<label for="lastname">Last Name</label>
<input type="text" name="lastname" id="lastname" />
</div>
<div class="required-field">
<label for="username">Username</label>
<input type="text" name="username" id="username" />
</div>
<div class="required-field">
<label for="email">Email</label>
<input type="text" name="email" id="email" />
</div>
</fieldset>
</form>

Download:

jquery.validation.js