jQuery Validation, multiple form ids for same function
- by George
Hi have two forms with the exact same validation rules, but different ids that I'd like to combine into just one function. How can I do that?
var validator = $("#ValidateForm1").validate({
errorPlacement: function(error, element) {
if ( element.is(":radio") )
error.appendTo( element.parent().next().next() );
else if ( element.is(":checkbox") )
error.appendTo ( element.next() );
else
error.appendTo( element.parent().next() );
}
});
var validator = $("#validateForm2").validate({
errorPlacement: function(error, element) {
if ( element.is(":radio") )
error.appendTo( element.parent().next().next() );
else if ( element.is(":checkbox") )
error.appendTo ( element.next() );
else
error.appendTo( element.parent().next() );
}
});