I want to prevent double click on submit button.
My code is...
onclick='this.style.visibility = "hidden";'
But it also hidden if i enter wrong entry. I want to disable button on double click but button enable in validation wrong entry
I want to prevent double click on submit button.
My code is...
onclick='this.style.visibility = "hidden";'
But it also hidden if i enter wrong entry. I want to disable button on double click but button enable in validation wrong entry
use this instead :
onclick="this.disabled=true;"
And for Double click event you could use :
ondblclick="this.disabled=true;"
jQuery.fn.preventDoubleSubmission = function() {
var last_clicked, time_since_clicked;
$(this).bind('submit', function(event){
if(last_clicked)
time_since_clicked = event.timeStamp - last_clicked;
last_clicked = event.timeStamp;
if(time_since_clicked < 2000)
return false;
return true;
});
};
Using like this:
$('#my-form').preventDoubleSubmission();
Your question is not clear. But based on my understanding, the tips below may help you.
To disable button on double click you can write code for that in .dblclick() jquery event. if there is any validation error, enable the button again.