Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trycf/7b8590667278453962df9783ccfc5abb to your computer and use it in GitHub Desktop.
Save trycf/7b8590667278453962df9783ccfc5abb to your computer and use it in GitHub Desktop.
TryCF Gist
<cfscript>
function checkExamples(examples){
loop list="#examples#" item="email" delimiters="#chr(10)##chr(13)#"{
ok = isValid("email", email)
if (ok)
echo ("#email#<br>");
else
echo ("<b>#email# FAIL</b><br>");
}
echo("<hr>");
}
</cfscript>
<!--- examples from from https://en.wikipedia.org/wiki/Email_address#Local-part --->
<cfsavecontent variable="valid_examples">
simple@example.com
very.common@example.com
disposable.style.email.with+symbol@example.com
other.email-with-hyphen@example.com
fully-qualified-domain@example.com
user.name+tag+sorting@example.com
x@example.com
example-indeed@strange-example.com
admin@mailserver1
example@s.example
" "@example.org
"john..doe"@example.org
mailhost!username@example.org
user%example.com@example.org
</cfsavecontent>
<cfsavecontent variable="invalid_examples">
Abc.example.com
A@b@c@example.com
a"b(c)d,e:f;g<h>i[j\k]l@example.com
just"not"right@example.com
this is"not\allowed@example.com
this\ still\"not\\allowed@example.com
1234567890123456789012345678901234567890123456789012345678901234+x@example.com
i_like_underscore@but_its_not_allow_in_this_part.example.com
</cfsavecontent>
<h1>valid examples</h1>
<cfscript>
checkExamples(valid_examples);
</cfscript>
<h1>invalid examples</h1>
<cfscript>
checkExamples(invalid_examples);
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment