Sencilla funcion javascript que se encarga de validar los caracteres alfanumericos.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
<script type="text/javascript"> function IsAlphaNum( str ) { // Return immediately if an invalid value was passed in if (str+"" == "undefined" || str+"" == "null" || str+"" == "") return false; var isValid = true; // convert to a string for performing string comparisons. str += ""; // Loop through length of string and test for any alpha numeric // characters for (i = 0; i < str.length; i++) { // Alphanumeric must be between "0"-"9", "A"-"Z", or "a"-"z" if (!(((str.charAt(i) >= "0") && (str.charAt(i) <= "9")) || ((str.charAt(i) >= "a") && (str.charAt(i) <= "z")) || ((str.charAt(i) >= "A") && (str.charAt(i) <= "Z")))) { isValid = false; break; } } // END for return isValid; } // end IsAlphaNum </SCRIPT> |