We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

buscarini on 05/09/08


Tagged

alfanumrico


Versions (?)


Si un carácter es alfanumérico o no


Published in: JavaScript 


  1. function alphanumeric(val){
  2. var regex=/^[0-9A-Za-z]+$/;
  3. if(regex.test(val)){
  4. return true;
  5. }
  6. else {
  7. return false;
  8. }
  9. }
  10.  
  11. function blah(e){
  12. var keynum = null;
  13. if(window.event) // IE
  14. {
  15. keynum = e.keyCode;
  16. }
  17. else if(e.which) // Netscape/Firefox/Opera
  18. {
  19. keynum = e.which;
  20. }
  21.  
  22. if ( (keynum!=null)&& (alphanumeric(keynum) )
  23. {
  24. // Se ha pulsado un alfanumérico
  25. }

Report this snippet 

Comments

RSS Icon Subscribe to comments
Posted By: zabaletgmailcom on May 13, 2008

function alphanumeric(val) { return /^[0-9A-Za-z]+$/.test(val); }

You need to login to post a comment.