I want to make the submit invisible on a submit so that the user cannot keep clicking on it while the server is receiving the file transfer.
The webpage will change after the submission, so un-hiding of the button should not be an issuse. Or so I thought.
Given a rough puesdo code of:
Expand|Select|Wrap|Line Numbers
- <script type="text/javascript>
- function HideMe()
- {
- document.getElementById("mysubmit").style.visibility="hidden";
- document.getElementById("coversheet").style.visibility="visible";
- }
- </script>
- <form>
- <input type="file" id="myfile" />
- <br/>
- <input type="submit" id="mysubmit" onclick="HideMe()">
- <span id="coversheet" style="visibility:hidden;">Please wait...</span>
- </form>
However, if you consider that a user can enter "sdgrthkzujhsfg " into the file upload textbox and click submit, we run into the problem.
The javascript onclick fires and changes the visibility of the two objects, BUT it never actually makes a page submission because "sdgrthkzujhsfg " is inccorect? (Note: "c:\sdgrthkzujh sfg" triggers a submission with roughly the same as "no file") So the user is left with no submission button and a "please wait...", even though the website is not doing any processing.
I have also tried the OnSubmit() event with the same result.
I found success(for the most part) with onbeforeunload( ) on the body element, but as I understand it there is some standards issues between browsers?
I tried using the onunload() event but you never see the result (the visibility does not change)
Can anyone recomend anything to only hide the submit button when a submit is actually going to happen? And not when their is the "sdgrthkzujhsfg " type situation?