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?
This error happened because I had another html element with same id. After removing that id code worked fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With