Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Wednesday, November 27, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: E-Mail Validation
RJ Eaton
Posts: 234
 
E-Mail ValidationYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Feb 07 10:21 AM
fiogf49gjkf0d
Everyone, I am using the pattern matching suggested in the artical on SLXDeveloper.. However within the code I am trying to understand the actual pattern.. Here is the code

+++++++++ CODE +++++++++++
' check the syntax of an email address (TRUE/FALSE)
Function CheckEmailAddress(strEMail)
Dim objRegExp, iMatches, sPattern

' search pattern of valid email address:
' valid characters are: a-z, 0-9, ., -, _
' only one @-sign is allowed; minimum is one dot after @-sign, number of
' characters after last dot is 2 chars, maximimum is 4 chars

sPattern = "^[\w\.\-]+@([\w\-]+\.)*[\w\-]{2,63}\.[a-zA-Z]{2,4}$"

' leave function and return false when parameter is empty
If len(trim(StrEMail)) = 0 Then
CheckEmailAddress = False
Exit Function
End If

' generate new regular expression
Set objRegExp = New RegExp
objRegExp.Pattern = sPattern
objRegExp.IgnoreCase = True
Set iMatches = objRegExp.Execute(strEMail)

If iMatches.Count = 1 Then
CheckEmailAddress = True
Else
CheckEmailAddress = False
End If

Set objRegExp = Nothing

End Function


++++++++ CODE ++++++++++++

My question is .. which part of the "Pattern" is responsible for the underscore charater being viewed as acceptable

Thanks for the help

Rich
[Reply][Quote]
Trevor Loflin
Posts: 7
 
Re: E-Mail ValidationYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Feb 07 10:39 AM
fiogf49gjkf0d
In this type of regexp, the "\w" represents a "word" character, which is alphanumeric plus underscore.

Just to break it down:
^ = from the beginning of the string
[\w\.\-]+ = match any "word" character, period, or dash one or more times
@ = match the "@" character
([\w\-]+\.)* = match one or more "word" characters or dashes, followed by a period, any number of times (including none at all)
[\w\-]{2,63} = match from two to 63 "word" characters or dashs
\. = match a period
[a-zA-Z]{2,4} = match 2 to 4 alphabetic characters
$ = and the string should end immediately
[Reply][Quote]
RJ Eaton
Posts: 234
 
Re: E-Mail ValidationYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Feb 07 10:44 AM
fiogf49gjkf0d
Thanks Trevor.. Just wondering why the Underscore would be failing then...
[Reply][Quote]
RJ Eaton
Posts: 234
 
Duplicate postYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Feb 07 10:44 AM
fiogf49gjkf0d
Duplicate Post
[Reply][Quote]
Trevor Loflin
Posts: 7
 
Re: E-Mail ValidationYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Feb 07 10:47 AM
fiogf49gjkf0d
What precisely is failing (you can, of course, change the alphanumeric characters for privacy reasons)? I'd need to see a specific example to know for sure. Of course, it's always possible there's a bug in the regexp parser.
[Reply][Quote]
RJ Eaton
Posts: 234
 
Re: E-Mail ValidationYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Feb 07 10:49 AM
fiogf49gjkf0d
E-mnail that fails is like:

john_Doe@company.state.gov

[Reply][Quote]
Trevor Loflin
Posts: 7
 
Re: E-Mail ValidationYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Feb 07 11:03 AM
fiogf49gjkf0d
Well, I just ran your code myself and it accepted both john_Doe@company.state.gov and johnDoe@company.state.gov, so I'm not sure what to tell you. Are you sure it's this function that's the problem?
[Reply][Quote]
RJ Eaton
Posts: 234
 
Re: E-Mail ValidationYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Feb 07 11:26 AM
fiogf49gjkf0d
Ok your response prompted me to check further.. the user had cut and pasted the e-mail address and it contained a space at the end of the string. that was what was cauing it to fail...

Amazing.. I actually heard a great comment... another support person told me....

"Application was working perfectly and then the user did something magical.. and now we get this error...!!"

Thanks for the help all

Rich
[Reply][Quote]
Trevor Loflin
Posts: 7
 
Re: E-Mail ValidationYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Feb 07 11:27 AM
fiogf49gjkf0d
Heh. Glad you figured it out. Good luck with your users.

By the way, presumably you're going to modify your code to trim the string, right?
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/27/2024 4:46:34 AM