title: How do I make it so only numbers 0-9 can be entered into prompt window in JavaScript?
body: <p>I need to be able to only enter the numbers 1 through to 9 in my prompt window. At the moment, I can enter any character I want and it will still work. How do I restrict this to numbers only? Here is the code I have so far:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;button onclick="myFunction()"&gt;Start Game&lt;/button&gt;
  &lt;button&gt;Stop Game&lt;/button&gt;
  &lt;br/&gt;
  &lt;br/&gt;
  &lt;p&gt;&lt;font size="20"&gt;Your chosen number is:&lt;/font&gt;&lt;/p&gt;
  &lt;span id="number"&gt;&lt;/span&gt;
  &lt;br/&gt;
  &lt;br/&gt;
  &lt;p&gt;&lt;font size="20"&gt;Your score so far is:&lt;/font&gt;&lt;/p&gt;
  &lt;br/&gt;
  &lt;span id="gamedisplay"&gt;&lt;/span&gt;
  &lt;span id="gamedisplay2"&gt;&lt;/span&gt;
  &lt;span id="gamedisplay3"&gt;&lt;/span&gt;
  &lt;span id="gamedisplay4"&gt;&lt;/span&gt;
  
  &lt;script&gt;
  function myFunction() {
  var integer = prompt("Please enter an integer between 1 and 9");
  if (integer != null) {
    document.getElementById("gamedisplay").innerHTML =
    Math.floor(Math.random() * 10);
    document.getElementById("gamedisplay2").innerHTML =
    Math.floor(Math.random() * 10);
    document.getElementById("gamedisplay3").innerHTML =
    Math.floor(Math.random() * 10);
    document.getElementById("gamedisplay4").innerHTML =
    Math.floor(Math.random() * 10);
   }
  }
  &lt;/script&gt;
  
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>