Find() returns the position of the "found" character.

<cfoutput>#find("@", "[email protected]")#</cfoutput>

Returns 6.

So your logic needs to be:

<CFIF find("@","#form.recipient_user_name#") NEQ 0 AND
find(".","#form.recipient_user_name#") NEQ 0>


Zero means no match was made -- so you need to look for conditions --
either NEQ 0 or GTE 1.

HTH,
.Peter

Jason Allen said the following on 09/03/2010 02:02 PM:
> HI Guys,
>
> I have a small piece of code that needs to check if a variable
> contains an email address.
>
> I want to check to make sure the string contains @ and .
>
> I've been trying a bunch of different ways since I realized what I
> originally had wasn't working. I never had problems with this, but I'm
> revisiting a script that uses 'find' and now i'm not getting results.
>
> I've tried
>
> <CFIF find("@,.","#form.recipient_user_name#") EQ 1 >
>
> <CFIF find("@,.",form.recipient_user_name) EQ 1 >
>
> <CFIF find("@","#form.recipient_user_name#") EQ 1 AND
> find(".","#form.recipient_user_name#") EQ 1>
>
> <CFIF find("@",form.recipient_user_name) EQ 1 AND
> find(".",form.recipient_user_name) EQ 1>
>
> And the variable form.recipient_user_name does contain an email
> address (with my tests) and it still won't come back positive.
>
> What am I doing wrong? Could this be related to OpenBD because I swear
> this worked before.
>
>   

-- 
Open BlueDragon Public Mailing List
 http://www.openbluedragon.org/   http://twitter.com/OpenBlueDragon
 official manual: http://www.openbluedragon.org/manual/
 Ready2Run CFML http://www.openbluedragon.org/openbdjam/

 mailing list - http://groups.google.com/group/openbd?hl=en

Reply via email to