April 11, 2012
Jquery form validation – pop up to specific checkbox
Question by holian
I use Jquery form validation. Before visitor submit i need to check the ‘Terms&Cond’ checkbox. If not checked i would like to see the message an alert box. (other messages shown near in the textboxes)
How to set this? I try this:
$("#myform").validate({
errorPlacement: function(error, element) {
if ( element.is(":checkbox") ) {
alert(error.html());
}
},
rules: {
name: {
required: true,
minlength: 3,
maxlength: 40,
lettersonly: false
},
ad: {
.....
But this did not work.
Thank you for help.
Answer by Starx
error
does not have a html() function. You were probably trying to alert the markup of the element.
alert(element.html());