title: Javascript function that restricts numeric functions but allow alphanumeric values
body: <p>i am stuck in a problem...This is my code which restricts special characters but i want a logic which will restricts special characters,numerics but allow alphanumeric values...
  for eg: </p>
  
  <ul>
  <li>valid   : a1,4r,aa. </li>
  <li><p>invalid : w@,12,@!.</p>
  
  <p>function check(e)</p></li>
  </ul>
  
  <p>{</p>
  
  <pre><code>var keynum;
  var keychar;
  var numcheck;
  if(window.event) // IE
  {
      keynum = event.keyCode;
  }
  else if(e.which) // netscape/Firefox/opera
  {
      keynum = e.which;
  }
  
  //condition for backspace(8) Key
  if(keynum != 8)
  {
      keychar = String.fromCharCode(keynum);
      numcheck = /[a-zA-Z0-9]*[a-zA-Z]+[a-zA-Z0-9]*/;
      return numcheck.test(keychar);
  }
  else
  {
      return true;
  }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>    User id : &lt;input type="text" id="txtname" name="txtname" onkeypress="return check(event)"/&gt;
  </code></pre>