title: Only accept number from 1 to 9 Using JavaScript
body: <p>Would like to know how to only accept number to be entered into inputbox from 1 to 9 and if entered for example 0 give alert message, sorry not a valid number.</p>
  
  <p>please check my function that i have done so far, but not working.. thank you</p>
  
  <pre><code>&lt;input name="number1" type="text" size="1" id="number1"onkeyup="doKeyUpValidation(this)/&gt;
  
  doKeyUpValidation(text){
  var validationRegex = RegExp(/[-0-9]+/, "g");
  if(!validationRegex.match(text.value)
  {
   alert('Please enter only numbers.');
  }
  </code></pre>