code_junkie

What is the best approach for (client-side) disabling of a submit button?

Nov 10th, 2011
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. $('input[type=submit]').click(function() { this.disabled = true; });
  2.  
  3. $('form').submit(function() {
  4. $('input[type=submit]', this).attr("disabled","disabled");
  5. });
  6.  
  7. $('form').submit(function() {
  8. $(this)
  9. .find(":submit,:image") // get all the submit buttons
  10. .attr({ disabled : 'disabled' }) // disable them
  11. .end() // go back to this form
  12. .submit(function() { // change the onsubmit to always reject.
  13. return false;
  14. })
  15. ;
  16. });
  17.  
  18. <html>
  19. <head>
  20. <script type="text/javascript" src="include/js/prototype.js"></script>
  21.  
  22. <script type="text/javascript">
  23. function handleSubmit()
  24. {
  25. $('submit').hide();
  26. $('progressWheel').show();
  27. return true;
  28. }
  29. </script>
  30. </head>
  31. <body>
  32. <img src="include/images/progress-wheel_lg.gif" id="progressWheel" style="display:none;"/>
  33. <input type="submit" name="submit" id="submit" value="Submit" onclick="handleSubmit();"/>
  34. </body>
  35. </html>
  36.  
  37. $('#SubmitButtonID').click(function() { this.disabled = true; });
  38.  
  39. function disableSubmit() {
  40. document.getElementById('btnContinue3').onclick = function() {
  41. alert('Please only click once on the submit button!'); return false;
  42. };
  43. }
Add Comment
Please, Sign In to add comment