我无法让 jQuery 的验证插件正常工作。我成功地引入了 jquery.js 和 jquery.validate.js。我的脚本如下:
$(document).ready(function($) {
$("#apply").validate({
rules: {
firstname: "required",
surname: "required",
secret: {
required: true,
minlength: 5
},
verify_secret: {
required: true,
minlength: 5,
equalTo: "#secret"
},
email: {
required: true,
email: true
},
},
messages: {
firstname: "Please enter your firstname",
surname: "Please enter your surname",
secret: {
required: "Please provide a password",
minlength: "Your password must be at least 5 characters long"
},
verify_secret: {
required: "Please provide a password",
minlength: "Your password must be at least 5 characters long",
equalTo: "Please enter the same password as above"
},
email: "Please enter a valid email address",
}
});
});
这是我的标记:
<form method="post" action="apply.php" id='apply'>
<input type='text' name='firstname' id='firstname' value=''/>
<input type='text' name='surname' id='surname' value=' '/>
<input type='text' name='email' id='email' value='Your Email Address'/>
<label for='secret'>Your Chosen Password</label>
<input type='password' name='secret' id='secret'/>
<label for='verify_secret'>Verify Your Password</label>
<input type='password' name='verify_secret' id='verify_secret'/>
<input type='submit' name='submit' value='Submit'/>
</form>
我缺少一些依赖项吗?我没有收到任何错误消息或任何其他可能帮助我解决问题的信息。