Since the Jquery Validation form validation plug-in is applied in the project, it is necessary to submit the form and then disable the button after the Validation verification is completed.
There is a DisableBtnPostBack project on CodeProject, but it cannot be combined with Jquery Validation. The code is posted first to remind everyone not to use this code in this situation. The code is as follows:
js:
Code
function disableBtn(btnID, newText) {
Page_IsValid = null;
if (typeof (Page_ClientValidate) == 'function') {
Page_ClientValidate();
}
var btn = document. getElementById(btnID);
var isValidationOk = Page_IsValid;
if (isValidationOk !== null) {
if (isValidationOk) {
btn.disabled = true;
btn.value = newText ;
btn.style.background = "url(12501270608.gif)";
}
else {
btn.disabled = false;
}
}
else {
setTimeout("setImage('" btnID "')", 10);
btn.disabled = true;
btn.value = newText;
}
}
function setImage (btnID) {
var btn = document.getElementById(btnID);
btn.style.background = 'url(12501270608.gif)';
}
Front-end page Code:
Code
onclick="btnOne_Click"
OnClientClick="disableBtn(this.id, 'Submitting...')"
UseSubmitBehavior="false" />
Okay, the following code can solve the problem of disabling the submit button after completing the Form verification of the Validation plug-in and submitting the Form:
js:
Code
$(document).ready(function() {
$("#myForm").validate({
submitHandler: function(form) {
$(form).find(":submit").attr("disabled", true).attr("value ",
"Submitting...");
form.submit();
}
})
});
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn