Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CFIF statement to validate email address

Posted on 2009-04-13
3
Medium Priority
?
255 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Use Filtering Commands to Process Files in Linux

Learn how to manipulate data with the help of various filtering commands such as `cat`, `fmt`, `pr`, and others in Linux.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

715 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