I cannot get this to work for the life of me. I need the Submit button to disable only after all validation is complete and then for the page to post to the OnClick function.
I have a form filled with RequiredFieldValidators and a ValidationSummary. Right now it validates and the button gets disabled but the page doesn't continue to post, it just stays stuck on this state:
My button
<asp:Button ID="Button3" runat="server" OnClick="Submit_Form" CssClass="btn btn-primary"
Text="Submit" OnClientClick="return disableOnSubmit(this);" />
JS to disable the button
<script type="text/javascript">
function disableOnSubmit(target) {
if (typeof (Page_ClientValidate) == 'function') {
if (Page_ClientValidate() == false) { return false; }
}
target.value = 'Please wait...';
target.disabled = true;
return true;
}
</script>
I am trying to prevent the user from submitting the form twice. The button should disable once they click it before it takes them to the next page.