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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple e-mail validation

Status
Not open for further replies.

sevex

Programmer
Sep 18, 2001
74
CA
I'm trying to validate an e-mail address by checking for an @ symbol, but it doesn't seem to be finding it. The following code:

<cfoutput>#email# #Find(email, &quot;@&quot;)#</cfoutput>

yields the following result:

email@email.ca 0

which doesn't make a lot of sense to me. Am I doing something wrong?
 
The code syntax is incorrect, the substring needs to be first.

Syntax
Find(substring, string
Code:
[
, start
Code:
]
)


=== START CODE EXAMPLE ===
<cfset email = &quot;
Code:
email@email.ca
&quot;
>

<cfoutput>#email# #Find(&quot;@&quot;, email)#</cfoutput>
=== END CODE EXAMPLE ===


A better option would be to use a Regular Expression

=== START CODE EXAMPLE ===
<cfset email = &quot;
Code:
email@email.ca
&quot;
>

<cfoutput>#email# #REFind(&quot;^
Code:
[
^@%*<>
Code:
]
+@
Code:
[
^@%*<>
Code:
]
{2,255}\.
Code:
[
^@%*<>
Code:
]
{2,5}&quot;
, trim(email))#</cfoutput>
=== END CODE EXAMPLE === - tleish
 
thanks a bunch! syntax error, how embarrasing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top