I have a form like this below:
<form id="gb">
<div><input type="text" name="a" value="" /></div>
<div><input type="text" name="b" value="" /></div>
<div><input type="submit" name="s" value="Submit" /></div>
</form>
And i using jquery.serialize() method for serialization:
$('form#gb').submit(function() {
$catch = $(this).serialize();
/* This produces a query string:
a=XXXX&b=XXXXX */
...
/* i want to validate a & b here */
...
$.ajax({
/* My Ajax Code */
});
});
i want to validate a & b value before ajax action, how to do this?
Always do server side validation. This being said, if you want to add client side validation before you do server side validation checkout this jquery validation plugin.
http://docs.jquery.com/Plugins/Validation#Example
Javascript
HTML