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.