Prevent Premature clicking on a submit button while page is refreshed
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Prevent Premature clicking on a submit button while page is refreshed

From: <anonieko@hotmail.com>
Date: Sun Aug 14 2005 - 23:46:08 CEST

Scenario: You have a page that is TOO slow to refresh.
But it allows partial flushing of html contents. I.e.
Submit button already appears but you don't
want your users to click on it prematurely
because other parts are still coming.

Here I put a javascript the will enable only
submit button only after 5 seconds after the page
is load fully.

The prevention of button being clicked twice
is also done .

<html>
<head>
</head>
<body>

<form id="testForm" >
<input id="test" type=text>
<input type=button value="1click only" onclick="dosubmit()">
</form>

<script type="text/javascript">
<!--
  var submitted = false;
  var timer1=setTimeout('EnableClick()', 5000);

  function EnableClick() {
          if (typeof submitted == 'undefined') return false;
          submitted = false;
  }

  function dosubmit(method) {
        // prevent clicking twice
    if (typeof submitted == 'undefined') return false;
    if ( submitted ) return false;
    submitted = true;
    clearTimeout(timer1);
    document.testForm.submit();
 }
-->
</script>

</body
Received on Tue Oct 18 03:08:59 2005