|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
||||
|
||||
|
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 |
|
#2
|
||||
|
||||
|
Never mind, "findNoCase" to the rescue.
![]() |
|
#3
|
|||
|
|||
|
There is a custom tag available for server-side checking email-address-syntax..
See the attachment.
__________________
** 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*] |
|
#4
|
||||
|
||||
|
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. ![]() |
|
#5
|
|||
|
|||
|
Quote:
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 ![]() |
|
#6
|
||||
|
||||
|
There, Happy?!
![]() |
|
#7
|
|||
|
|||
|
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 |
|
#8
|
|||
|
|||
|
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>
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Validating an Email Address |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|