Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery validation plugin error: TypeError: validator is undefined

Tags:

Here is html code for the form:

<form method="post" id="login" action="/login">  <div class="login-element">     <label for="email">E-Mail</label>     <input type="text" name="email"> </div> <div class="login-element">     <label for="password">Passwort</label>     <input type="password"  name="password"> </div> <div class="login-element">     <input type="submit" value="Login"> </div> </form> 

and here is the code that I used for validation:

    $(document).ready(function() {      $("#login").validate({        debug: true,        rules: {             email: {               required: true,               email: true             },             password: {               required: true             }         },         messages: {             email: {                 required: "Please enter a email adress",                 email: "Please enter a valid email address"             },             password:"Please enter password"         }     });     }); 

In the console following error is logged:

TypeError: validator is undefined ...or.settings[eventType] && validator.settings[eventType].call(validator, this[0],... 

What could be the issue here?

like image 567
Damir Mitrovic Avatar asked Sep 13 '12 13:09

Damir Mitrovic


1 Answers

This error happened because I had another html element with same id. After removing that id code worked fine.

like image 112
Damir Mitrovic Avatar answered Oct 02 '22 10:10

Damir Mitrovic