ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old August 19th, 2004, 02:28 PM
wdn2000's Avatar
wdn2000 wdn2000 is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Apr 2000
Posts: 1,058 wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 6 Days 20 h 56 m 43 sec
Reputation Power: 16
Validating an Email Address

This is probably really easy to do, but due to me lack of CF knowledge I'm not sure where to start. I need some basic server-side validation for email addresses. Client-side won't work because I'm getting this data from a database, not user input.

More than anything I just want a way to check for the presence of an @ symbol in the string, but I didn't see any string functions that looked like they'd fit the bill.

Any help appreciated,
wdn2k

Reply With Quote
  #2  
Old August 19th, 2004, 03:55 PM
wdn2000's Avatar
wdn2000 wdn2000 is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Apr 2000
Posts: 1,058 wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 6 Days 20 h 56 m 43 sec
Reputation Power: 16
Never mind, "findNoCase" to the rescue.

Reply With Quote
  #3  
Old August 20th, 2004, 04:30 AM
DeepDown DeepDown is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Netherlands
Posts: 99 DeepDown User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 1 m 8 sec
Reputation Power: 5
There is a custom tag available for server-side checking email-address-syntax..
See the attachment.
Attached Files
File Type: zip emailcheck.zip (792 Bytes, 277 views)
__________________
** Don't expect me to code your needs, but if I am able to help, I'm willing. Shout, grab and use the hand!
** Man can no more own the land we walk upon, as they can lay claim on the air that we breath
** DeepDown I'm addicted to structures.... ohw and music
** Almost forgot I had an account here [*o*]

Reply With Quote
  #4  
Old August 21st, 2004, 10:39 PM
Alas's Avatar
Alas Alas is offline
Wickedwd.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: wickedwd.com
Posts: 182 Alas Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 16 h 41 m 17 sec
Reputation Power: 0
Post Quick Freebie Crashcourse

1.Validate that username is 4-11 characters long:

Code:
<cfif Len(form.Username) LTE 4 OR Len(form.Username) GTE 11> ERROR!!<cfelse> Proceed</cfif>


2.Make sure the confirm password = password

Code:
 <cfelseif #Trim(form.ConfirmPassword)# NEQ #Trim(form.Password)#> ERROR!!!


3.Ensure that Usernames are not already taken

1st write a cfquery called search then...

Code:
<cfif Search.RecordCount GTE 1> ERROR <cfelse> Proceed </cfif>


4.And finally email validation

<CFSET Alas = @>
Code:
<Cfif (Len(form.email) IS NOT 0) AND (Alas > 1) PROCEED <cfelse> ERROR </cfif> 


THIS IS MY GOOD DEED OF THE MONTH...FOR ALL THOSE WHO HAVE HELPED ME.

Reply With Quote
  #5  
Old August 22nd, 2004, 03:52 AM
DeepDown DeepDown is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Netherlands
Posts: 99 DeepDown User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 1 m 8 sec
Reputation Power: 5
Quote:
Originally Posted by Alas
1.Validate that username is 4-11 characters long:

Code:
<cfif Len(form.Username) LTE 4 OR Len(form.Username) GTE 11> Proceed <cfelse> ERROR </cfif>




Euhm, this check will give an error if the username is 5-10 characters long...
And euh.. is this post related to the actual question..
Nevermind...

Anyway, swap your operators and use an AND instead of an OR

Reply With Quote
  #6  
Old August 22nd, 2004, 02:24 PM
Alas's Avatar
Alas Alas is offline
Wickedwd.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: wickedwd.com
Posts: 182 Alas Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 16 h 41 m 17 sec
Reputation Power: 0
There, Happy?!

Reply With Quote
  #7  
Old August 22nd, 2004, 02:52 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,611 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 10 m 21 sec
Reputation Power: 53
In addition to the solution provided by Alas, you could use regular expressions to verify email addresses. There are also some nice custom tags available in the developer's exchange (cf_emailverify, etc.).
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #8  
Old August 22nd, 2004, 08:50 PM
dirtybbq dirtybbq is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 53 dirtybbq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 17 m
Reputation Power: 6
I use the following function to validate an e-mail address:

Code:
<cfscript>
function validate_email(email) {
  ret_val = "true";

  if(not len(trim(arguments.email)) or
     not refind("^[0-9A-Za-z.'+_-]+@([0-9A-Za-z-]+\.)+[A-Za-z]+$", trim(arguments.email))) {
    ret_val = "false";
  }

  return ret_val;
}
</cfscript>

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Validating an Email Address


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway