function is_valid_email(email:String):Boolean
{
var emailRgx:RegExp = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
///^[a-zA-Z0-9][-._a-zA-Z0-9]*@([a-zA-Z0-9]*.)+[a-zA-Z]{2,6}$/;
trace(emailRgx.test(email));
return emailRgx.test(email);
}
is_valid_email("c@j.co");
Tag Archive for email
Actionscript email validation
Check validation email adres
function is_valid_email($email)
{
if(preg_match("/[a-zA-Z0-9_-.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+/", $email) > 0)
return true;
else
return false;
}
Email this page
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Ronnie T. Moore -->
<!-- Web Site: The JavaScript Source -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! <a href="http://javascript.internet.com" >http://javascript.internet.com</a> -->
<!-- Begin
function initMail(form) {
text = "Check out this page: " + window.location;
form.message.value = "Hi " + form.sendto.value + " (" + form.to.value + "):
"
+ text + "
Your Friend,
" + form.sendername.value + "(" + form.senderemail.value + ")";
return (form.to.value != "");
}
// End -->
</script>
//////////////////////////////////////////////////////////////////////////////
//include this form content to pages that you may want to show.
<center>
<form name=emailform method=post action="http://cgi.freedback.com/mail.pl" target="_new" onSubmit="return initMail(this);">
<input type=hidden name=subject value="** Check Out This Site! **">
<input type=hidden name=message value="">
<table>
<tr><td colspan=2 align=center>Tell a friend about this page!</td></tr>
<tr><td>Their Name:</td><td><input type=text name=sendto></td></tr>
<tr><td>Their Email:</td><td><input type=text name=to></td></tr>
<tr><td>Your Name:</td><td><input type=text name=sendername></td></tr>
<tr><td>Your Email:</td><td><input type=text name=senderemail></td></tr>
<tr><td colspan=2 align=center><input type=submit value="Ok!"></td></tr>
</table>
</form>
</center>
Encode Email against spammers
function encode_email($e)
{
for ($i = 0; $i < strlen($e); $i++) { $output .= '&#'.ord($e[$i]).';'; }
return $output;
}
ultimate validate email function
<?php
function validateEmail($email)
{
$isValid = true;
$atIndex = strrpos($email, "@");
if (is_bool($atIndex) && !$atIndex)
{
$isValid = false;
}
else
{
$domain = substr($email, $atIndex+1);
$local = substr($email, 0, $atIndex);
$localLen = strlen($local);
$domainLen = strlen($domain);
if ($localLen < 1 || $localLen > 64)
{
// local part length exceeded
$isValid = false;
}
else if ($domainLen < 1 || $domainLen > 255)
{
// domain part length exceeded
$isValid = false;
}
else if ($local[0] == '.' || $local[$localLen-1] == '.')
{
// local part starts or ends with '.'
$isValid = false;
}
else if (preg_match('/../', $local))
{
// local part has two consecutive dots
$isValid = false;
}
else if (!preg_match('/^[A-Za-z0-9-.]+$/', $domain))
{
// character not valid in domain part
$isValid = false;
}
else if (preg_match('/../', $domain))
{
// domain part has two consecutive dots
$isValid = false;
}
else if
(!preg_match('/^(\.|[A-Za-z0-9!#%&`_=/$'*+?^{}|~.-])+$/',
str_replace("\","",$local)))
{
// character not valid in local part unless
// local part is quoted
if (!preg_match('/^"(\"|[^"])+"$/',
str_replace("\","",$local)))
{
$isValid = false;
}
}
if ($isValid && !(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A")))
{
// domain not found in DNS
$isValid = false;
}
}
return $isValid;
}
?>
link
<?php
function encode_mailto($mail, $label, $subject = "", $body = "") {
$chars = preg_split("//", $mail, -1, PREG_SPLIT_NO_EMPTY);
$new_mail = "<a href="mailto:";
foreach ($chars as $val) {
$new_mail .= "&#".ord($val).";";
}
$new_mail .= ($subject != "" && $body != "") ? "?subject=".$subject."&body=".$body : "";
$new_mail .= "">".$label."</a>";
return $new_mail;
}
?>
Validate Email
function validate_email($email)
{
return preg_match("/^[-_a-z0-9'+*$^&%=~!?{}]++(?:.[-_a-z0-9'+*$^&%=~!?{}]+)*+@(?:(?![-.])[-a-z0-9.]+(?<![-.]).[a-z]{2,6}|d{1,3}(?:.d{1,3}){3})(?::d++)?$/iD",$email);
}
JavaScript – is_valid_email
function is_valid_email (email)
{
return /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/.test(email);
}