View Full Version : javascript email
texerasmo
20-01-2004, 10:45
Ciao qulacuno di voi ha la funzione javascript per il controllo della della casella email?
Grazie in anticipo
Controllo dell'email in JavaScript ? Ma per la shell o per un sito web ? Non credo che sia possibile...
texerasmo
20-01-2004, 11:40
sito web
ho questa (presa da jsdir )ma ha un bug
mi valida un indizzo del genere
nome@dominio.,com
function emailControl(emailInput)
{
// Controllo il formato dell'indirizzo e-mail. rstituisce true o false
var StrMail;
StrMail=emailInput;
if (StrMail.length>6)
{
var pos;
var dotpos;
pos = StrMail.indexOf("@");
if ( (pos >= (StrMail.length-3) ) || (pos < 2) )
{
return (false);
}
pos=pos+1;
dotpos = StrMail.indexOf(".", pos);
if (dotpos > (StrMail.length-3) )
{
return (false);
}
Strmail=StrMail.substr(pos);
if ( (StrMail.length < 5) || (dotpos <= 0) )
{
return (false);
}
}
else
{
return (false);
}
return true;
}
</SCRIPT>
askatasuna
20-01-2004, 13:43
Prova con questa..
function validate()
{
myEmail = document.myForm.myEmail.value
var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
if (!email_reg_exp.test(myEmail) || (myEmail== "") || (myEmail== "undefined")) {
alert("Inserire un indirizzo email corretto.");
return false;
}
else
{
alert("Inserito correttamente")
}
}
ciauz
ask
Ah....validazione ;) Allora sė...quello sopra dovrebbe essere corretto...
vBulletin® v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.