Categories :

How to prevent multiple clicks on submit button in jQuery?

<script type=”text/javascript”>
    function ValidationEvent() {
      if (name != ” && email != ” && contact != ”){
          return true;
       }
       return false;
    }

    var Validation_result = false;

    jQuery(“#enquiry_form”).submit(function(e){
       if (jQuery(‘#enquiry_submit_btn’).data(‘dont’) == 1)return;
   
       // submit button disabled for click
       jQuery(‘#enquiry_submit_btn’).data(‘dont’, 1);
      
       // Validation
       Validation_result = ValidationEvent();
      
       if(Validation_result == false){
        // submit button enable for click
        jQuery(‘#enquiry_submit_btn’).data(‘dont’, 0); 
       }
    });

    jQuery(‘#enquiry_reset_btn’).click(function(){
       jQuery(‘#enquiry_form’)[0].reset();
       // submit button enable for click
       jQuery(‘#enquiry_submit_btn’).data(‘dont’, 0); 
    });
</script>

2 Replies to “How to prevent multiple clicks on submit button in jQuery?”

Leave a Reply

Your email address will not be published. Required fields are marked *