I am using the jQuery Validation Plugin. When I make more then one click on submit button, the alert of success message show me more then one time. How to prevent multiple clicks on submit button?
$(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'));
});
});
}
});
});
You can disable the submit button. Or you can replace the submit button with a "Processing..." text.