Disable the submit button after it's pressed - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Submit

Description

Disable the submit button after it's pressed

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <p>Click the button to trigger a function.</p> 
      <button id="demo">Click me</button>  
      <script>

var nbSubmits = 0;/*w w  w .j a  v  a  2  s . c  o m*/
document.getElementById("demo").onclick = function (){
    nbSubmits++;
    if(nbSubmits == 20) {
        document.getElementById("demo").disabled="true";
    }
}

      </script> 
   </body>
</html>

Related Tutorials