我正在使用这个插件:jQuery Validate
我有一个这样的基本形式:
HTML
<form class="cmxform" id="signupForm" method="get" action="">
<fieldset>
<legend>Validating a complete form</legend>
<label for="firstname">Firstname</label>
<input id="firstname" name="firstname" type="text" />
<label for="lastname">Lastname</label>
<input id="lastname" name="lastname" type="text" />
<label for="username">Username</label>
<input id="username" name="username" type="text" />
<label for="password">Password</label>
<input id="password" name="password" type="password" />
<label for="confirm_password">Confirm password</label>
<input id="confirm_password" name="confirm_password" type="password" />
<input class="submit" type="submit" value="Submit"/>
</fieldset>
</form>
jQuery
$().ready(function() {
// validate signup form on keyup and submit
$("#signupForm").validate({
rules: {
firstname: "required",
lastname: "required",
username: {
required: true,
minlength: 2
},
password: {
required: true,
minlength: 5
},
confirm_password: {
required: true,
minlength: 5,
equalTo: "#password"
},
email: {
required: true,
email: true
}
},
messages: {
firstname: "Please enter your firstname",
lastname: "Please enter your lastname",
username: {
required: "Please enter a username",
minlength: "Your username must consist of at least 2 characters"
},
password: {
required: "Please provide a password",
minlength: "Your password must be at least 5 characters long"
},
confirm_password: {
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"
}
});
});
我想让密码需要一个大写字母并包含至少一个数字。
我将如何仅更改密码规则并将其添加?
这是一个小提琴: