Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email Address Confirmation 1

Status
Not open for further replies.

varnix

Programmer
Joined
Jan 7, 2002
Messages
94
Location
US
One of the scripts I am writing uses the CFMAIL tag to send a confirmation email back to the user with their information.

Since this is on an internal intranet we have a list of all approved email addresses within our system.

Our email consists of first.last@domain.com - we have been able to pull the first.last out of the submitted form field using spanexcluding(form.email,"@") and then testing for a valid email address.

However, we also need to test the @domain.com portion to make sure that people spell it right. This has been an issue for us in the past unfortunately - people who can't spell the domain name, let alone their own name properly.

Thanks!

Roger Pray
Systems Analyst
MIBH
 
If it is the same domain name consistently you could use something like:

<cfset tempdname=#Left(form.email,12)# <!-- 12 is the number of characters in the domain name including the .com -->

<cfif tempdname = &quot;tek-tips.com&quot;>
pass form
<cfelse>
return to form to correct
</cfif>

This could also be done on the client side with javascript and an onsubmit event in the form tag.


Hope this helps The only dumb questions are the ones that are never asked
 
Thanks for the help, the only change I had to make was to change it from left(email,12) to right(email,12). Using left it gave me the username and not the domain name.

I didn't even know about those commands!

Thanks again!
 
Sorry for the mixup. Good catch though. The only dumb questions are the ones that are never asked
 
You could also use a regular expression:

<cfscript>
form.email = &quot;
Code:
first.last@domain.com
&quot;
;

vRegXemail = &quot;^(
Code:
[
a-zA-Z
Code:
]
+).(
Code:
[
a-zA-Z
Code:
]
+)\@(
Code:
[
Code:
[
a-zA-Z0-9_.-
Code:
]
+)\.(
Code:
[
a-zA-Z
Code:
]
{2,3})$&quot;
;

vFname = ReReplace(form.email, variables.vRegXemail, &quot;\1&quot;);
vLname = ReReplace(form.email, variables.vRegXemail, &quot;\2&quot;);
vDomain = ReReplace(form.email, variables.vRegXemail, &quot;\3&quot;);
vExt = ReReplace(form.email, variables.vRegXemail, &quot;\4&quot;);

</cfscript>

<cfoutput>
[COLOR=000080]<b>[/color]First Name:[COLOR=000080]</b>[/color] #variables.vFname#[COLOR=000080]<br>[/color]
[COLOR=000080]<b>[/color]Last Name:[COLOR=000080]</b>[/color] #variables.vLname#[COLOR=000080]<br>[/color]
[COLOR=000080]<b>[/color]Domain:[COLOR=000080]</b>[/color] #variables.vDomain#[COLOR=000080]<br>[/color]
[COLOR=000080]<b>[/color]Domain Extension:[COLOR=000080]</b>[/color] #variables.vExt#[COLOR=000080]<br>[/color]
</cfoutput> - tleish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top