
10/08/2007, 13:07
|
 | | | Fecha de Ingreso: abril-2007
Mensajes: 91
Antigüedad: 17 años, 10 meses Puntos: 2 | |
Re: Busqueda de validacion de email <!-- DOS PASOS PARA VALIDAR LA DIRECCION DE EMAIL:
1. Copiar el script dentro del <HEAD></HEAD>
2. Copiar el código del formulario dentro de <BODY></BODY> -->
1.Script de Validación
<HEAD>
<SCRIPT LANGUAGE="Javascript">
<!-- Principio
function emailCheck (emailStr) {
/* Verificar si el email tiene el formato user@dominio. */
var emailPat=/^(.+)@(.+)$/
/* Verificar la existencia de caracteres. ( ) < > @ , ; : \ " . [ ] */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* Verifica los caracteres que son válidos en una dirección de email */
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
/* Verifica si la dirección de email está representada con una dirección IP Válida */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* Verificar caracteres inválidos */
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
alert("Email address seems incorrect (check @ and .'s)")
return false
}
var user=matchArray[1]
var domain=matchArray[2]
// Si el user "user" es valido
if (user.match(userPat)==null) {
// Si no
alert("El nombre de usuario no es válido.")
return false
}
/* Si la dirección IP es válida */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("IP de destino inválida")
return false
}
}
return true
}
var domainArray=domain.match(domainPat)
if (domainArray==null) {
alert("El dominio parece no ser válido.")
return false
}
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 ||
domArr[domArr.length-1].length>3) {
alert("La dicrección debe tener 3 letras si es ."com" o 2 si en de algún pais.")
return false
}
if (len<2) {
var errStr="La dirección es erronea"
alert(errStr)
return false
}
// La dirección de email ingresada es Válida
return true;
}
// End -->
</script>
</head>
<!-- PASO DOS: Archivo HTML -->
<BODY>
<center>
<form name=emailform onSubmit="return emailCheck(this.email.value);">
Your Email Address: <input type=text name="email"><br>
<input type=submit value="Submit">
</form>
</center>
esto no me recuerdo de donde lo obtuve...
pero ahi te lo envio
espero que te ayude
bye |