I ran into the same problem and i used following plugin, it is working pretty well.
Official Plugin Page
http://jqueryvalidation.org/
GitHub
https://github.com/jzaefferer/jquery-validation
CDN
http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js
EXAMPLE CODE:
It can be used easily as followed with AJAX: (if you want without AJAX simply edit that part)
<form id="example_form" action="process.php" method="POST" novalidate="novalidate">
<span style="display: none;" id="success">Success</span>
<span style="display: none;" id="failure">Failure</span>
<label for="Name">Name:<br>
<input type="text" id="txtName" required="" class="required">
</label>
<label for="Phone">Contact No:<br>
<input type="tel" id="txtPhone" required="" class="required number">
</label>
<label for="Email">Email:<br>
<input type="email" id="txtEmail" required="" class="required email">
</label>
<button type="submit">Submit</button>
</form>
$(function()
{
var form = $("#example_form").validate();
$("form#example_form").submit(function() {
if(form.valid())
{
var name = $("#txtName").val();
var email = $("#txtEmail").val();
var phone = $("#txtPhone").val();
$.ajax({
url: "process.php",
type: "POST",
data: {
'name': name,
'email': email,
'phone': phone
},
dataType: "json",
success: function(data) {
if(data.status == 'success')
{
$('#success').show();
}
else if(data.status == 'error')
{
$('#failure').show();
}
}
});
return false;
}
});
});