title: disable button in specific time using js
body: <p>I am trying to disable the button base on time. If the time exceeds 5pm then the button will disable. I got my code but I don't know if it is the proper. Please help me to solve this . sorry I'm not that good in javascript.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --&gt;
      &lt;title&gt;&lt;/title&gt;
  
      &lt;!-- Bootstrap --&gt;
      &lt;link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"&gt;
  
      &lt;!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --&gt;
      &lt;!-- WARNING: Respond.js doesn't work if you view the page via file:// --&gt;
      &lt;!--[if lt IE 9]&gt;
          &lt;script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"&gt;&lt;/script&gt;
          &lt;script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"&gt;&lt;/script&gt;
          &lt;![endif]--&gt;
      &lt;script&gt;
          function startTime() {
              var today = new Date();
              var h = today.getHours();
              var m = today.getMinutes();
              var s = today.getSeconds();
              m = checkTime(m);
              s = checkTime(s);
              document.getElementById('txt').innerHTML =
                  h + ":" + m + ":" + s;
              var t = setTimeout(startTime, 500);
          }
          function checkTime(i) {
              if (i &lt; 10) { i = "0" + i };  // add zero in front of numbers &lt; 10
              return i;
          }
  
          function buttonTime() {
              if (checkTime() &gt; 17) {
                  document.getElementById('button').disabled = true;
              } else {
                  document.getElementById('button').disabled = false;
              }
          }
      &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body onload="startTime()"&gt;
  
      &lt;div id="txt"&gt;&lt;/div&gt;
      &lt;form action="login.php"&gt;
          &lt;button class="btn btn-info" id="button" type="submit"&gt; Submit &lt;/button&gt;
      &lt;/form&gt;
  
      &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>