Reputation: 173
I have written the code below but even if I enter the fields it shows the error message, also how can I stop the button click if there is another method assigned if it shows error messages.
<script src="js/jquery-1.11.1.min.js"></script>
<script src="bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.15.0/jquery.validate.js"></script>
<script src="js/snip.js"></script>
<script src="js/action.js"></script>
<script>
$('#reg_form').validate({
rules:{
FirstName:{
required:true
},
Email:{
required:true,
email:true
},
ConfirmEmail:{
required:true,
email:true,
equalTo:"#Email"
},
code:{
number:true
},
Mobile:{
number:true
}
},
messages:{
FirstName:{
required:"Please enter your First Name"
},
Email:{
required:"Please provide an Email address",
},
ConfirmEmail:{
required:"Please provide an Email address",
equalTo:"Please provide same Email address"
}
}
});
$('button').on('click',function(){
if($('#reg_form').valid()==true)
$(this).stop();
});
</script>
Here is the link to the page
Upvotes: 1
Views: 281
Reputation: 12796
You're calling $('#reg_form').validate()({...});
. I.e. you're calling validate()
with no options and expecting it to return a function, which you're then immediately calling, passing-in options.
You just have a typo; you need to remove the ()
after validate
so that your options are passed into the validate
function.
Upvotes: 2