title: JavaScript to accept only numbers between 0 to 255 range
body: <p>My Requirement is to validate the ip ranges, I need to create a JavaScript function to accept only numeric and it must allow only between the range 0 to 255. If anything is entered beyond that it must alert a message. </p>
  
  <p>I am currently using this below function </p>
  
  <pre><code>&lt;script language="JavaScript"&gt; 
  
  function allownums(a) 
  { 
  
  if(a &lt;48 ||a &gt; 57) 
  alert("invalid") 
  else 
  alert("vaild") 
  } 
  
  &lt;/script&gt; 
  &lt;input type='text' id='numonly' onkeypress='allownums(event.keycode)'&gt; 
  </code></pre>
  
  <p>I am new to JavaScript, Need some experts suggestion to fix my requirement. Please suggest me</p>
  
  <p>Thanks
  Sudhir</p>