ورود

View Full Version : سوال: چک کردن آدرس ایمیل



rash44
شنبه 07 شهریور 1388, 09:20 صبح
سلام دوستان
شکل تابعی که آدرس ایمیل را اعتبار سنجی کنه به چه صورت هست ؟
منظروم از شکل تابع کاراکترهای باقاعده هست

ahmadbadpey
شنبه 07 شهریور 1388, 10:44 صبح
فكر مي كنم اين نمونه خوبي باشه :

function checkEmail(inputvalue){
var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
if(pattern.test(inputvalue)){
alert("true");
}else{
alert("false");
}
}

yasgig
شنبه 07 شهریور 1388, 12:00 عصر
<table border="0" class="content" cellpadding="3" style="border-collapse: collapse" width="100%" id="1" dir="rtl">
<tr>
<form name="Contactform" method="post" action="index.php" onSubmit="return CheckFormYasgig();">
</td>
</tr>
<tr>
<td align=right width="970">ایمیل:</td>
<td align=right width="131">
<INPUT size=25 name=email class="textbox" maxlength="60" dir="ltr">
</td>
</tr>
<tr>
<td align=right height="25" colspan="2">
<p align="center">
<INPUT type=submit value="ثبت" name="submit" class="content" style="float: right">
</tr>
</table>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<SCRIPT language="JavaScript">
function CheckFormYasgig () {

//Initialise variables
var errorMsg = "";

//Check for an e-mail address and that it is valid
if ((document.Contactform.email.value == "") || (document.Contactform.email.value.length > 0 && (document.Contactform.email.value.indexOf("@",0) == - 1 || document.Contactform.email.value.indexOf(".",0) == - 1))) {
errorMsg += "\n\n\t آدرس ايميل شما بطور صحيح وارد نشده است ";
}

//If there is aproblem with the form then display an error
if (errorMsg != ""){
msg = "\t\t : لطفا به خطا های زیر توجه فرمایید\n";
msg += "__________________________________________________ _";

errorMsg += alert(msg + errorMsg + "\n________________________________________________ ___\n\n");
return false;
}

return true;
}
// -->
</script>
<body>موفق باشید!

mostafa_shaeri_tj
شنبه 07 شهریور 1388, 20:10 عصر
با این تابع هم جواب میگیری . فکر می کنم ساده تر و قابل فهم تر باشه . البته این نظر منه :




function validate_email(field,alerttxt){with (field){apos=value.indexOf("@");dotpos=value.lastIndexOf(".");if (apos<1||dotpos-apos<2) {alert(alerttxt);return false;}else {return true;}}}