Javascript 让Bootstrap 3 popover与jQuery validate一起使用
我正在尝试验证表单,并使用Bootstrap3弹出窗口通知用户无效的表单数据。我有以下javascript代码来处理验证:Javascript 让Bootstrap 3 popover与jQuery validate一起使用,javascript,jquery,twitter-bootstrap,Javascript,Jquery,Twitter Bootstrap,我正在尝试验证表单,并使用Bootstrap3弹出窗口通知用户无效的表单数据。我有以下javascript代码来处理验证: $(document).ready(function() { $('#signup').validate({ rules: { signup_email: { required: true, maxlength: 45 },
$(document).ready(function() {
$('#signup').validate({
rules: {
signup_email: {
required: true,
maxlength: 45
},
signup_password: {
required: true,
minlength: 8
},
'signup[confirm_password]': {
required: true,
equalTo: "#signup_password"
}
},
messages: {
signup_email: {
required: "Please enter your email address",
maxlength: "Your email address is too long!"
},
signup_password: {
required: "Please enter a password",
minlength: "Your password must be at least 8 characters long."
},
'signup[confirm_password]': {
required: "Please retype your password",
equalTo: "Passwords do not match!"
}
},
errorElement: 'span',
errorClass: 'error',
validClass: 'success',
highlight: function(element, errorClass) {
$(element).popover('show');
},
unhighlight: function(element, errorClass) {
$(element).popover('hide');
},
errorPlacement: function(err, element) {
err.hide();
}});
$('#signup_email').popover({
placement: 'below',
offset: 20,
trigger: 'manual'
});
$('#signup_password').popover({
placement: 'below',
offset: 20,
trigger: 'manual'
});
$('#signup_confirm_password').popover({
placement: 'below',
offset: 20,
trigger: 'manual'
});
});
以及以下html表单:
<input type="email" id="signup_email" name="signup[email]" required="required" class="form-control" placeholder="Email" rel="popover" />
<input type="password" id="signup_password" name="signup[password]" required="required" class="form-control" placeholder="Password" rel="popover" />
<input type="password" id="signup_confirm_password" name="signup[confirm_password]" required="required" class="form-control" placeholder="Retype Password" rel="popover" />
<button type="submit" id="signup_send" name="signup[send]" class="btn btn-default">Let's go.</button>
让';我们走吧。
当我提交表单时,验证工作正常,但没有显示弹出窗口。有人知道这可能是什么原因吗
'signup[confirm_password]': {
required: true,
equalTo: "#signup_password"
}
'signup[confirm_password]': {
required: "Please retype your password",
equalTo: "Passwords do not match!"
}
注册[确认密码]应为注册确认密码