title: javascript regex to disallow all special characters
body: <p>Here is a fiddle to start - <a href="http://jsfiddle.net/zuVpx/1/" rel="nofollow">http://jsfiddle.net/zuVpx/1/</a></p>
  
  <p><strong>Javascript code:</strong></p>
  
  <pre><code>&lt;script&gt;
      function validate(e) {
          var regex = new RegExp("[a-zA-Z0-9]");
          var key = e.keyCode || e.which;
          key = String.fromCharCode(key);
  
          if(!regex.test(key)) {
              e.returnValue = false;
              if(e.preventDefault) {
                  e.preventDefault();
              }
          }
      }
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>HTML code:</strong></p>
  
  <pre><code>&lt;input type="text" onkeypress="validate(event)" /&gt;
  </code></pre>
  
  <p>I want only characters and numbers. Keys like backspace, delete, capslock and arrowkeys etc should work.</p>
  
  <p>Thanks in advance.</p>