I have a form which is sent to an email address when user clicks Send. The form is validated first. I want to show 'Please wait' text to the user when he clicks the button. Now 'Please wait' text shows fine if the form fields are valid and the form is sent normally. But if there is an error in the form fields the 'Please wait' text still shows and I don't want that.
Now I'm using JavaScript, here the script:
<script language="javascript" type="text/javascript">
function showPleaseWait()
{
document.getElementById('PleaseWait').style.display = 'block';
}
</script>
Here is Send button (uses onMouseDown) and PleaseWait div (which is shown):
<asp:Button ID="btnSend" runat="server" Text="Send Order" Enabled="true" ValidationGroup="Validate" onMouseDown="showPleaseWait()" CausesValidation="false" />
<div id="PleaseWait" style="display: none;">Sending, please wait.</div>
I'm trying to get into the validation first and if it passes ok, then show the Please Wait text. It doesn't work if I try to show the PleaseWait div in the beginning of btnSend. How should I do this?
Many thanks for your help!