Say i have a form that looks up city, state locations. if the user enters an incorrect city, state, i want the form to be able to check the database against the users input
If you're trying to get a particular validation method to fire ONLY on the submit event while allowing other validation methods to fire normally (e.g., on the onkeyup event), then you can dynamically add the rule when the submit event fires, then remove it after the validation is performed. The ordering of the bindings is important; keep them in order.
$('#form').bind('submit', function(event) {
$('#citystate').rules('add', {myCustomAjaxSyncronousCheckAgainstDBRule: true});
event.preventDefault();
});
$('#form').validate({
rules: {
citystate: { required: true }
}
});
$('#form').bind('submit', function(event) {
$('#citystate').rules('remove', 'myCustomAjaxSyncronousCheckAgainstDBRule');
event.preventDefault();
});