Reputation: 225
HTML code:
<div id="form_pwd">
<form method="POST" action="google.com" id="pwdChange">
<table>
<tr>
<td width="175px"><label for="newPwd">Enter your password</label></td>
<td><input type="password" name="newPwd" id="newPwd" size="35"/></td>
</tr>
<tr>
<td><label for="newPwd_">Re-enter your password</label></td>
<td><input type="password" name="newPwd_" id="newPwd_" size="35"/></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Save Password" /></td>
</tr>
</table>
</form>
</div>
jQuery code:
$(document).ready(function()
{
$("#form_pwd").validate(
{
rules:
{
newPwd: "required",
newPwd_:
{
equalTo: "#newPwd"
}
}
}
);
}
);
I use the above source to validate my input passwords but there is nothing being shown next to the text boxes, would someone please have a look and help me spot it ? i already include
<script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
<script type="text/javascript">
jQuery.validator.setDefaults({
debug: true,
success: "valid"
});
</script>
at the top of the file. :(
[Update]Ok, the demo is here http://jsfiddle.net/Z9JmB/2/
I hope someone could help me out with this tiny problem. Thank you sooo much .
Upvotes: 0
Views: 430
Reputation: 50787
This works fine, but you're targeting the div outside of the form. You need to change the target element from:
$("#form_pwd")
to:
$("#pwdChange")
This will target your form.
Also, in your JS fiddle, you need to include your validation js file. I updated the jsfiddle to include the validation plugin your using, it all works 100% correctl, please have a look:
Upvotes: 3
Reputation: 23542
This looks fine. Make sure your password input has id="newPwd"
or post more code. Maybe setup a jsfiddle.net
Also see manual http://docs.jquery.com/Plugins/Validation/Methods/equalTo#other
Upvotes: 0