sunny
sunny

Reputation: 3891

jQuery (...).validate is not a function

My browser console is telling me that:

$(...).validate is not a function

I am simply trying to reproduce this example, but it is not working, and I've no idea why. Looking at the networking console, I see that there is no file load error. Also my cache is clear and turned off, so I should be looking at the right source. What else could be going wrong?

Here's the full code on the page:

<form id="myform">
    <input type="text" name="field1" />
    <br/>
    <input type="text" name="field2" />
    <br/>
    <input type="submit" />
</form>


<script src="jquery-1.8.3.min.js"></script> 

<script>

$(document).ready(function () {

    $('#myform').validate({ // initialize the plugin
        rules: {
            field1: {
                required: true,
                email: true
            },
            field2: {
                required: true,
                minlength: 5
            }
        },
        submitHandler: function (form) { // for demo
            alert('valid form submitted'); // for demo
            return false; // for demo
        }
    });

});


</script>

Upvotes: 0

Views: 671

Answers (2)

Barr J
Barr J

Reputation: 10929

You need to include jQuery validation plugin:

<script type="text/javascript" src="path-to/jquery-validate.js"></script>

download it and attach to your project.

Upvotes: 3

Jamiec
Jamiec

Reputation: 136114

The example you point to uses jQuery validate plugin, you've not included that in your example.

Upvotes: 2

Related Questions