Given an email address, say: [email protected]
In Coldfusion, how can i validate that the email is from "google.com" and not another domain?
Given an email address, say: [email protected]
In Coldfusion, how can i validate that the email is from "google.com" and not another domain?
If you are only looking for a specific domain, it might be easier to just use some string operations.
I don't know coldfusion, but something akin to
addr.lastIndexOf("@google.com")
If it's not -1, then it's from the domain you're looking for.
if(email.substring(email.indexOf("@") + 1) == "google.com")
print("valid");
Okay, here is the answer in CFML :)
<cfset email = "[email protected]" />
<cfif ListLast(email, "@") EQ "google.com">
Horray!
</cfif>
EDIT
Specially for Amarghosh. We can do it this way, no worries:
<cfscript>
email = "[email protected]";
if (ListLast(email, "@") == "google.com") {
// here you go
}
</cfscript>
You just want to compare the domain of an e-mail address?
listLast("[email protected]","@") IS "google.com"
is one way to do it.