I used jquery validation (http://bassistance.de/jquery-plugins/jquery-plugin-validation/) for form validation. The followings are some fragments of my code:
HTML:
<
Summing up, in order to employ both form validation and ajax submission, add 'submitHandler' to the validate() function:
$("#formID").validate({
onkeyup:false,
rules: {
...
},
messages: {
...
},
// Submit the form
submitHandler: function(form) {
theUrl = '/processData';
var params = $(form).serialize();
$.ajax ({
type: "POST",
url: theUrl,
data: params,
processData: false,
async: false,
success: function(returnData) {
$('#content').html(returnData);
}
});
}
});