/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function alphanumeric(val){ var regex=/^[0-9A-Za-z]+$/; if(regex.test(val)){ return true; } else { return false; } } function blah(e){ var keynum = null; if(window.event) // IE { keynum = e.keyCode; } else if(e.which) // Netscape/Firefox/Opera { keynum = e.which; } if ( (keynum!=null)&& (alphanumeric(keynum) ) { // Se ha pulsado un alfanumérico }