我正在使用jQuery 验证插件。当我点击提交按钮不止一次时,成功消息的警报会显示不止一次。如何防止多次点击提交按钮?
$(document).ready(function() {
$('#contact-us').validate({
rules: {
cName: 'required',
email: 'required',
cText: 'required'
},
messages: {
cName: '<?php echo $errorName; ?>',
email: '<?php echo $errorEmail; ?>',
cText: '<?php echo $errorComment; ?>'
},
submitHandler: function(form) {
var formInput = $(this).serialize();
$.post($(this).attr('action'), formInput, function(data){
$('#contact-us').fadeOut('fast', function(){
$(this).before($('<p class="alert alert-success"><?php _e( 'Your message was sent successfully. Thanks!' ); ?></p>').fadeIn('fast'));
});
});
}
});
});