Reputation: 291
I Want to validate a for with jquery form validation. So i include the following coads.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2 /jquery.min.js"></script>
<script type="text/javascript" src=" http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
<script type="text/javascript">
$(function() {
$('#contact-form').validate({
rules:{
name:{
required:true
},
email:{
required:true,
email:true
}
}
});
});
</script>
But when i am clicking the submit button then an error is shown like
TypeError: $("#contact-form").validate is not a function
Help me.
Upvotes: 0
Views: 4484
Reputation:
Make sure jquery and jquery.validate load successfully. You can call the function as above but usual way is to call it document.ready. Hope it helps.
Upvotes: 0
Reputation: 31033
it works here http://jsfiddle.net/UWhJE/
make sure the jquery is loaded before you include the validate.js. Also check for javascript errors in the firebug console (for firefox) or in chrome development tools
Upvotes: 1
Reputation: 3732
You have a weird space breaking up your jQuery script include url. You're probably getting console errors about the script not loading if you'd look.
/1.7.2 /
Needs to be
/1.7.2/
Upvotes: 2