Jquery form validation - pop up to specific checkbox

581 views Asked by At

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.

2

There are 2 answers

0
Starx On

error does not have a html() function. You were probably trying to alert the markup of the element.

alert(element.html());
0
luchosrock On

in line 3, it should be: if ( element.is(":checked") ) {