Re: validating email CF11
With all the new top level domains available now (), you are better with a regex that matches by size, instead of adding specific strings beyond 3 or 4 characters. Just change the {2,4} to something like {2,254}, which should fairly future proof the regex. I believe the RFC for DNS has a maximum length of 253 for a domain, while the RFC for an email address is 254 for max length. http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains#ICANN-era_generic_top-level_domains http://en.wikipedia.org/wiki/Email_address Interesting to note, that many special characters are allowed in the local part and IPV4 and IPV6 addresses are allowed for the domain part of an email address. The first regex Robert provided will handle most typical email addresses however. I don't think I've seen an email with an IP domain in like forever, but if IPV6 every takes hold, it's very possible it would become typical at some point. ~Byron ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359970 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: validating email CF11
I would avoid IsValid() it is not reliable and has been blogged about. try this https://github.com/teamcfadvance/ValidateThis On Thu, Jan 15, 2015 at 2:48 PM, Rob Voyle robvo...@voyle.com wrote: Hi Folks Using CF11 isValid(email,name@gmail) is returning a Yes Am I missing something or is this a bug. As far as I know CF9 would have returned NO Rob Robert J. Voyle, Psy.D. Director, Clergy Leadership Institute For Coaching and Training in Appreciative Inquiry http://www.clergyleadership.com/ 503-647-2378 or 503-647-2382 ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359971 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: validating email CF11
You might want to look at Mailgun - http://www.mailgun.com/email-validation they have jquery implementation (https://github.com/mailgun/validator-demo) /S Ben mailto:b...@webworldinc.com January 15, 2015 at 9:35 AM Given how often TLDs are changing is there a way in CF to do a verification that the domain name exists? That would seem simpler. Ben ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359973 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: validating email CF11
isValid(email,name@gmail) is returning a Yes Am I missing something or is this a bug. As far as I know CF9 would have returned NO Well, it's not really a bug. Within certain contexts, that would in fact be a valid email address. It obviously wouldn't be a valid email address on a public network, but on an internal network you can have all sorts of wacky things. And validation of public addresses is a difficult thing, due to constant changes and the flexibility of characters allowed in email addresses for both the local and domain parts. I recommend that you not validate email addresses at all! As an end-user, I get very frustrated when I encounter forms that tell me that my (perfectly valid) email address is not valid (not dwa...@figleaf.com, but I have many email addresses). Taking a quick look, all of the validation functions provided in this thread would fail with those email addresses. I don't think any of them allow plus signs, for example, which are (a) valid characters and (b) used more often than you might think. Instead, consider simple, user-friendly alternatives. Perhaps you could just look for an @ character with preceding and following characters, then validate it by attempting to send an email to it. Use that email to allow the user to proceed, if it's something important, or tell the user that they should have received an email and if they don't get it, there may be a problem with their email address. Ask the user to enter it twice, if you like. Dave Watts, CTO, Fig Leaf Software 1-202-527-9569 http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Service-Disabled Veteran-Owned Small Business (SDVOSB) on GSA Schedule, and provides the highest caliber vendor- authorized instruction at our training centers, online, or onsite. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359975 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: validating email CF11
Given how often TLDs are changing is there a way in CF to do a verification that the domain name exists? That would seem simpler. Ben On Jan 15, 2015, at 10:06 AM, Byron Mann byronos...@gmail.com wrote: With all the new top level domains available now (), you are better with a regex that matches by size, instead of adding specific strings beyond 3 or 4 characters. Just change the {2,4} to something like {2,254}, which should fairly future proof the regex. I believe the RFC for DNS has a maximum length of 253 for a domain, while the RFC for an email address is 254 for max length. http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains#ICANN-era_generic_top-level_domains http://en.wikipedia.org/wiki/Email_address Interesting to note, that many special characters are allowed in the local part and IPV4 and IPV6 addresses are allowed for the domain part of an email address. The first regex Robert provided will handle most typical email addresses however. I don't think I've seen an email with an IP domain in like forever, but if IPV6 every takes hold, it's very possible it would become typical at some point. ~Byron ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359972 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: validating email CF11
DNS lookup might suffice just to verify the domain is valid (ie, registered). ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359974 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: validating email CF11
I had similar issues with this... use the script below instead of CF. You can do an onBlur=validateEmail(); on the email field. function validateEmail(){ var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; str = document.userform.email.value; if(!str.match(emailRegEx)){ alert(Please enter a valid email address (n...@domain.com).); userform.email.focus(); return false; } } Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.121 Direct Line: 516-302-4345 www.aimg.com -Original Message- From: Rob Voyle [mailto:robvo...@voyle.com] Sent: Thursday, January 15, 2015 9:49 AM To: cf-talk Subject: validating email CF11 Hi Folks Using CF11 isValid(email,name@gmail) is returning a Yes Am I missing something or is this a bug. As far as I know CF9 would have returned NO Rob Robert J. Voyle, Psy.D. Director, Clergy Leadership Institute For Coaching and Training in Appreciative Inquiry http://www.clergyleadership.com/ 503-647-2378 or 503-647-2382 ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359967 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: validating email CF11
Thanks Robert Your code limits TLD to 4 which would catch .museum What are people setting as a limit on TLDs Rob On 15 Jan 2015 at 9:53, Robert Harrison wrote: I had similar issues with this... use the script below instead of CF. You can do an onBlur=validateEmail(); on the email field. function validateEmail(){ var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; str = document.userform.email.value; if(!str.match(emailRegEx)){ alert(Please enter a valid email address (n...@domain.com).); userform.email.focus(); return false; } } ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359968 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: validating email CF11
Thanks, I'm aware. You can change that if you'd like, but so far from the 200 plus sites I've done, I've never has a .museum address. It could happen; someone does the museum sites :-) If you want another that uses CF and allows museum, you could try the function below... someone on the list gave me this ages ago. cffunction name=isEmail returntype=boolean access=public output=false cfargument name=email_address type=string required=true / cfscript var isOK = false; //supports new top level tlds if ( REFindNoCase(^['_a-z0-9-]+(\.['_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.(([a -z]{2,3})|(aero|coop|info|museum|name))$,arguments.email_address)) { isOK = true; } return isOK; /cfscript Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.121 Direct Line: 516-302-4345 www.aimg.com ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359969 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm