My webform has a submit button that triggers a javascript function. Here is the code for the button:
<asp:Button ID="btnSub" runat="server" Text="submit" OnClientClick="return processSub();" />
The javascript function being called looks like this:
function processSub(){
var btnId = '<%= btnSub.ClientID %>'
var userSelection = confirm('Are you sure you wish to submit');
if (userSelection){
document.getElementById(btnId).setAttribute("disabled","disabled");
return true;
} else {
return false;
}
}
I am facing an issue where the submission doesn't happen when I try to disable the submit button using
document.getElementById(btnId).setAttribute("disabled","disabled");
. However, it works fine when I comment out this line within the IF block.
Can anyone clarify why this happens and provide a solution on how to make it work? Please note that I am not using any JavaScript library and prefer not to use one. Thank you.