jQuery Validation, multiple form ids for same function
Posted
by George
on Stack Overflow
See other posts from Stack Overflow
or by George
Published on 2010-03-21T03:50:16Z
Indexed on
2010/03/21
3:51 UTC
Read the original article
Hit count: 612
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() );
}
});
© Stack Overflow or respective owner