javascript - jQuery validate function Does not work -


<script type="text/javascript">      jquery(function(){          jquery("#agree").validate({             expression: "if (!ischecked(selfid)) return false; else return true;",             message: "please agree terms , conditions"         });       });  </script>  <form> <input type="checkbox" value="agree" name="agree" id="agree"  /> <input type="submit"> </form> 

you need add validation form element , set required rule checkbox

<form id="myform">     <input type="checkbox" value="agree" name="agree" id="agree" />     <input type="submit"> </form> 

then

jquery(function ($) {     $("#myform").validate({         rules: {             agree: {                 required: true             }         },         messages: {             agree: "please agree terms , conditions"         }     }); }); 

demo: fiddle


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -