Pages

Tuesday 11 March 2014

Disable Submit button until form submit

         Following code disables the Submit button until form gets submit successfully. This is necessary because user may click more than once on submit button and the same data may be processed more than once. many time in Database table duplicate entry exist because of this issue. While submitting form the submit button will be get disabled and text on it will be changed to "Please wait...".

/*Disable button while adding record so repeatedly not added*/

$("input[type='submit']").attr("disabled", false);
$("form").submit(function () {
$("input[type='submit']").attr("disabled", true).val("Please wait...");
return true;
})
/*Here form is the Id of form tag*/

No comments:

Post a Comment