在我的页面中加载以下脚本后,我遇到了灯箱问题:
jQuery.validator.addMethod('answercheck', function (value, element) {
return this.optional(element) || /^\b5\b$/.test(value);
}, "please type the correct answer (this is anti-spam)");
// validate contact form
$(function() {
$('#contact').validate({
rules: {
name: {
required: true,
minlength: 2
},
email: {
required: true,
email: true
},
answer: {
required: true,
answercheck: true
}
},
messages: {
name: {
required: "please enter your name",
minlength: "your name must consist of at least 2 characters"
},
email: {
required: "please enter your email address"
},
answer: {
required: "sorry, wrong answer! (this is anti-spam)"
}
},
submitHandler: function(form) {
$(form).ajaxSubmit({
type:"POST",
data: $(form).serialize(),
url:"process.php",
success: function() {
$('#contact :input').attr('disabled', 'disabled');
$('#contact').fadeTo( "slow", 0.15, function() {
$(this).find(':input').attr('disabled', 'disabled');
$(this).find('label').css('cursor','default');
$('#success').fadeIn();
});
},
error: function() {
$('#contact').fadeTo( "slow", 0.15, function() {
$('#error').fadeIn();
});
}
});
}
});
});
我已阅读.live()并阅读此页面http://api.jquery.com/live/但我是新手并且在我的脚本中无法实现它。有什么帮助吗? 谢谢