I'm using jQuery and jQuery Validate Plugin on a test page, my code is based on validate demo
<html>
<head>
<script src="http://jquery.bassistance.de/validate/lib/jquery-1.9.0.js"></script>
<script type="text/javascript" src="scripts/jquery.validate.js"></script>
<script type="text/javascript">
$.validator.setDefaults({
submitHandler: function() { alert("submited!!!"); }
});
$().ready(function() {
$("#registerForm").validate({
rules : {
username: {
required: true,
minlength: 2
},
password: {
required: true,
minlenght: 5
},
confirm_password: {
required: true,
minlenght: 5,
equalTo: "#password"
},
email: {
required: true,
email: true
}
},
messages : {
username: {
required: "Please enter a username",
minlenght: "Your username must consist at least 2 characters"
},
password: {
required: "Please enter a password ",
minlenght: "Your password must consist at least 5 characters"
},
confirm_password: {
required: "Please repeat the password",
minlenght: "Your password must consist at least 5 characters",
equalTo: "This password doesn't match with the original password"
},
email: {
required: "Please enter a email",
email: "Invalid email"
}
}
});
});
</script>
<style type="text/css">
#commentForm { width: 500px; }
#commentForm label { width: 250px; }
#commentForm label.error, #commentForm input.submit { margin-left: 253px; }
#registerForm { width: 670px; }
#registerForm label.error {
margin-left: 10px;
width: auto;
display: inline;
color: red;
}
#newsletter_topics label.error {
display: none;
margin-left: 103px;
}
</style>
</head>
<body class="zoom: 1;">
<div id="main">
<form id="registerForm" method="post" action="" novalidate="novalidate">
<fieldset>
<legend>OLA MUNDO</legend>
<p><label for="username">Nome</label>
<input id="username" name="username" type="text" value=""></p>
<p><label for="email">E-mail</label>
<input id="email" name="email" type="email" value=""></p>
<p><label for="password">Password</label>
<input id="password" name="password" type="password" value=""></p>
<p><label for="confirm_password">Confirm Password</label>
<input id="confirm_password" name="confirm_password" type="password" value=""></p>
<p><input type="submit" class="submit" value="Enviar"></p>
</fieldset>
</form>
</div>
</fieldset>
</body>
The problem is that in my page the code doesn't work and i don't know why it happens.
I have a jquery.js file in my scripts directory but the script isn't loaded. So i used the jquery from the demo site, i used the jquery hosted on google and that doesn't solves the problem. I don't know if the problem is on the script code, because i'm kind of newbie on javascript.
@Edit
I solved the problem but now the password and confirm password field doesn't validate, why? the js code is correct