title: HTML5 + JS MinMax number input slight modification requested
body: <p>I have the following code which does exactly what I want - it keeps the range slider consistent with the number field, and doesn't allow text field values above the min or max. It also doesn't use jquery which is great.</p>
  
  <p>The problem however is that when I try to enter a custom number that may begin with a number lower than the min value, it will automatically replace it before I have a chance to enter a larger number. Eg: if min is 800 and I want to enter 1600, then I can't do this easily since pressing "1" in the text box will immediately replace it with 800. </p>
  
  <p>Here is the code: </p>
  
  <pre><code>      &lt;script type="text/javascript"&gt;
          function minmax(value, min, max)
          {
              if(parseInt(value) &gt; max)
                  return max;
              else if (parseInt(value) &lt; min)
                  return min;
              else return value;
          }
      &lt;/script&gt;
      &lt;form&gt;
          &lt;input type="range" name="amountRange" id ="amountRange" min="&lt;?php echo  $minRaise ?&gt;" max="&lt;?php echo $maxRaise ?&gt;"
                 value="&lt;?php echo  $minRaise ?&gt;" oninput="this.form.amountInput.value=this.value" /&gt;
          &lt;input type="number" name="amountInput" min="&lt;?php  echo $minRaise ?&gt;" max="&lt;?php echo $maxRaise ?&gt;" value="&lt;?php  echo $minRaise ?&gt;"
                 onkeyup="this.value = minmax(this.value, &lt;?php  echo $minRaise ?&gt;, &lt;?php echo $maxRaise ?&gt;)" oninput="this.form.amountRange.value=this.value" /&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>I thought about inserting a sleep function within the min check part of the faction using the JS sleep example found here: <a href="https://stackoverflow.com/questions/951021/what-is-the-javascript-version-of-sleep">What is the JavaScript version of sleep()?</a> . However unfortunately this resulted in a lot of regex and other errors in the console, leading me to believe there is a more elegant solution.</p>
  
  <p>Any ideas? It would be a shame if I had to butcher the entire code or use jQuery just for such a seemingly simple modification. Since this belongs to a php file loaded from an external jQuery call on another page, I'd rather not use jQuery here.</p>