我在看以下问题:jQuery 验证插件的密码确认问题
我复制了 jsfiddle 上的代码并相应地对其进行了编辑以使其在我的服务器上运行,但它似乎不起作用,我无法弄清楚!请帮忙,谢谢!
这是我的代码。
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
<script>
$.validator.setDefaults({
submitHandler: function() {
alert("submitted!");
}
});
// validate signup form on keyup and submit
$("form").validate({
rules: {
pass: {
required: true,
minlength: 5
},
pass2: {
required: true,
minlength: 5,
equalTo: "#pass"
}
},
messages: {
pass: {
required: "Please provide a password",
minlength: "Your password must be at least 5 characters long"
},
pass2: {
required: "Please provide a password",
minlength: "Your password must be at least 5 characters long",
equalTo: "Please enter the same password as above"
}
}
});
</script>
</head>
<body>
<form>
<table>
<tr>
<td>Password</td>
<td>
<label for="pass"></label>
<input id="pass" name="pass" type="password" value="" />
</td>
</tr>
<tr>
<td>Password confirm</td>
<td>
<label for="pass2"></label>
<input id="pass2" name="pass2" type="password" value="" />
</td>
</tr>
</table>
<input type="submit" name="save" value="Save" />
</form>
</body>
</html>