Solved

CFIF statement to validate email address

Posted on 2009-04-13
3
225 Views
Last Modified: 2012-05-06
Can someone help me write a CFIF statement to validate email address, I want to transfer email lists from other databases but i want to make sure all the emails that go into the new database are emails in the correct format. I use

validate="regular_expression"
pattern="[A-Za-z0-9_]+@[A-Za-z0-9_]+\.[A-Za-z]+"

for my form but i need to know how to use this in a CFIF tag??
0
Comment
Question by:overcolor
  • 2
3 Comments
 
LVL 19

Expert Comment

by:erikTsomik
ID: 24131646
try this
<cfinput type="text" name="email" message="Email address is impoperly formatted." validate="regular_expression" pattern="^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.(([a-z]{2,3})|(aero|coop|info|museum|name))$">
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 24131682
>  how to use this in a CFIF tag??

Try the IsValid(..) function:
http://livedocs.adobe.com/coldfusion/8/htmldocs/functions_in-k_37.html

<cfif IsValid("email", form.yourFieldName)>
it is valid
<cfelse>
 not valid
</cfif>

> I use  ... for my form

You could also just use <cfinput validate="email" ..>
0
 
LVL 52

Expert Comment

by:_agx_
ID: 24131710
erikTsomik wrote:
> try this <cfinput type="text" name="email" ....>

Personally, I would use validate="email" for the client side validation.  It is a lot simpler.  Though you could also use that expression on the server side. See the IsEmail function at cflib.org, for an updated version of that expression:

http://www.cflib.org/index.cfm?event=page.udfbyid&udfid=216
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now