// RESOURCES: // http://www.javascripts.astalaweb.com (miles de scripts) // http://www.ucm.es/info/dsip/Docencia/luis/JS/Tema21.pdf function SoloNumeros() { if(( event.keyCode >= 97 && event.keyCode <= 122) || (event.keyCode >=65 && event.keyCode <=90)) { event.keyCode=0; } } function trim(s) { while (s.substring(0,1) == ' ') { s = s.substring(1,s.length); } while (s.substring(s.length-1,s.length) == ' ') { s = s.substring(0,s.length-1); } return s; } function validarEmail( email) { caracNoValidos = " /:,;"; if( email == "") return false; // debe rellenarse for( i = 0; i < caracNoValidos.length; i++) { // ¿hay algún carácter no válido? caracMal = caracNoValidos. charAt( i); if( email. indexOf( caracMal, 0) > -1) return false; } posArroba = email. indexOf("@", 1); // debe haber una @ if( posArroba == -1) return false; if( email. indexOf("@", posArroba+ 1) != -1) return false; // y sólo una posPunto = email. indexOf(".", posArroba); if( posPunto == -1) return false; // y al menos un . tras la @ if( posPunto+ 3 > email. length) return false; // debe haber al menos 2 caracteres tras el . return true; } // fin de validarEmail() function validarTelefono(vTelefono) { strTelefono = vTelefono.toString(); if (strTelefono.length != 9) return false; if (strTelefono.substring(0,1) != "6" && strTelefono.substring(0,1) != "9") return false; if (isNaN(strTelefono)) { return false; } return true; }