Skip to content Skip to sidebar Skip to footer

JQuery Preventing Form From Being Submited Twice And On Enter Key

I have the this form:

Solution 1:

In your input fields, stick the word required somewhere in there and your function that is not the disableSubmit should no longer need to be called. Like so:

<input name="adress_search" type="text" id="AddressSearch" required />

Solution 2:

Just keep a variable that prevents multiple submissions:

jQuery(function($) {
    var submitting = false;

    $("#EventAddForm").submit(function(event) {
        if (submitting) {
            event.preventDefault();
            return;
        }
        submitting = true;
        // rest of code here
    });
});

Solution 3:

Since none of hte suggestions worked, I have been doing the reseach and found a solution that helped me. Hopefully, it will be useful for somebody in the future.

     var input = document.getElementById('AddressSearch'); 

        google.maps.event.addDomListener(input, 'keydown', function(e) { 
                if (e.keyCode == 13) 
                { 
                        if (e.preventDefault) 
                        { 
                                e.preventDefault(); 
                        } 
                        else 
                        { 
                                // Since the google event handler framework does not handle early IE versions, we have to do it by our self. :-( 
                                e.cancelBubble = true; 
                                e.returnValue = false; 
                        } 
                } 
        }); 

Post a Comment for "JQuery Preventing Form From Being Submited Twice And On Enter Key"