Solved

CFIF statement to validate email address

Posted on 2009-04-13
3
247 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 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

615 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