[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 247
  • Last Modified:

Validating Email

Hi I want to validate emails and I know how by using....

pattern="^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.(([a-z]{2,3})|(aero|coop|info|museum|name))$">

but...
I need to validate only 4 different types of domains.
@duq.edu, @wduq.org, @library.duq.edu, and @mathcs.duq.edu

I got this from another expert....

pattern="^[_a-z0-9-]+(\.[_a-z0-9-]+)*@duq.edu | ^[_a-z0-9-]+(\.[_a-z0-9-]+)*@wduq.org | ^[_a-z0-9-]+(\.[_a-z0-9-]+)*@library.duq.edu | ^[_a-z0-9-]+(\.[_a-z0-9-]+)*@mathcs.duq.edu"

unfortunately it doesn't work...

I need another suggestion....
0
nau2nd
Asked:
nau2nd
1 Solution
 
mrichmonCommented:
How about this:

Very similar, but with minor variations - because really that is the answer if you want to use the regular expression you stated.

^[_a-z0-9-]+(\.[_a-z0-9-]+)*@duq.edu$ | ^[_a-z0-9-]+(\.[_a-z0-9-]+)*@wduq.orgu$ | ^[_a-z0-9-]+(\.[_a-z0-9-]+)*@library.duq.edu$ | ^[_a-z0-9-]+(\.[_a-z0-9-]+)*@mathcs.duq.edu$



If it doesn't work then show some examples that are not working that you need to validate...
0
 
James RodgersWeb Applications DeveloperCommented:
how about this?

pattern="^[_a-z0-9-]+(\.[_a-z0-9-]+)*@(duq.edu | wduq.org | library.duq.edu | mathcs.duq.edu)$"
0
 
nau2ndAuthor Commented:
it still is not working

here is an email i try to input....i tried both solutions above and both will give me the validating message.

safura423@duq.edu

<cfinput type="text" name="EmpEmail" required="yes"
              validate="regular_expression"
            pattern="^[_a-z0-9-]+(\.[_a-z0-9-]+)*@duq.edu$ | ^[_a-z0-9-]+(\.[_a-z0-9-]+)*@wduq.orgu$ | ^[_a-z0-9-]+(\.[_a-z0-9-]+)*@library.duq.edu$ | ^[_a-z0-9-]+(\.[_a-z0-9-]+)*@mathcs.duq.edu$"
            message="Please enter your Duquesne email address. For questions or to reports problems please contact Kathy Jaczesko at 412-396-5311 or jaczesko@duq.edu" value="" size="49">
0
 
mosphatCommented:
How about this expression?

<cfset RE = "^['_a-z0-9-]+(\.['_a-z0-9-]+)*@(duq\.edu|wduq\.org|library\.duq\.edu|mathcs\.duq\.edu)$"/>

<cfoutput>
Returns 1:
#reFindNoCase(RE, "safura423@duq.edu")#

Returns 0:
#reFindNoCase(RE, "safura423@duq.com")#
#reFindNoCase(RE, "safura423@.edu")#
</cfoutput>

0
 
mosphatCommented:
The pattern I suggested, works with the examples provided by nau2nd. Therefore it is very likely to be the answer to the question.

Thanks.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now