我正在尝试用 jQuery 验证插件将验证添加到我的表单中,但是我遇到了一个问题,当我使用输入组时,该插件将错误消息放置在表单中。
$('form').validate({
rules: {
firstname: {
minlength: 3,
maxlength: 15,
required: true
},
lastname: {
minlength: 3,
maxlength: 15,
required: true
}
},
highlight: function(element) {
$(element).closest('.form-group').addClass('has-error');
},
unhighlight: function(element) {
$(element).closest('.form-group').removeClass('has-error');
}
});
我的代码: < a href = “ http://jsfiddle.net/hTPY7/4/”rel = “ norefrer”> http://jsfiddle.net/htpy7/4/