Código HTML:
function comprobar_email(this){
$mail_correcto = 0;
//compruebo unas cosas primeras
if ((strlen(this) >= 6) && (substr_count(this,"@") == 1) && (substr(this,0,1) != "@") && (substr(this,strlen(this)-1,1) != "@")){
if ((!strstr(this,"'")) && (!strstr(this,"\"")) && (!strstr(this,"\\")) && (!strstr(this,"\$")) && (!strstr(this," "))) {
//miro si tiene caracter .
if (substr_count(this,".")>= 1){
//obtengo la terminacion del dominio
$term_dom = substr(strrchr (this, '.'),1);
//compruebo que la terminación del dominio sea correcta
if (strlen($term_dom)>1 && strlen($term_dom)<5 && (!strstr($term_dom,"@")) ){
//compruebo que lo de antes del dominio sea correcto
$antes_dom = substr(this,0,strlen(this) - strlen($term_dom) - 1);
$caracter_ult = substr($antes_dom,strlen($antes_dom)-1,1);
if ($caracter_ult != "@" && $caracter_ult != "."){
$mail_correcto = 1;
}
}
}
}
}
if ($mail_correcto)
{
alert ("E-mail Incorrecto. Introduzca un correo valido. Ademas debes borrar la marca de 'Acepto todo lo expuesto' y volverla a marcar, para que se pueda habilitar el boton 'Registrar'");
return 1;
}
else
{ return 0; }
}
</script>
Código HTML:
<input name="txtmail" type="text" id="txtmail" size="20" maxlength="150" onChange="comprobar_email(this)">
![lloron](http://static.forosdelweb.com/fdwtheme/images/smilies/chillando.png)
Gracias
BYE
![Adios](http://static.forosdelweb.com/fdwtheme/images/smilies/adios.gif)