我使用 Bootstrap 3 登录表单。但是当我添加 jQuery Validation Plugin 它开始跳跃。所以问题是: 1. 我输入 Login (正确) 2. 然后我点击 Password 输入它,但 Password 的表单正在跳下。
jQuery.validator.addMethod("lettersonly", function (value, element) {
return this.optional(element) || /^[a-z0-9_-]+$/i.test(value);
}, "Please use only a-z0-9_-");
$('#form-signin').validate({
rules: {
login: {
minlength: 3,
maxlength: 15,
required: true,
lettersonly: true
},
password: {
minlength: 3,
maxlength: 15,
required: true,
lettersonly: true
},
},
highlight: function (element) {
$(element).closest('.control-group').addClass('has-error');
},
success: function (element) {
element.closest('.control-group').removeClass('has-error');
}
});