Solved

Regular Expression - allow emails with period in the name.

Posted on 2016-08-17
4
82 Views
Last Modified: 2016-08-17
I had ran into an issue previously where my regex expression wasn't allowing periods in the name for emails.  for example, my.email@gmail.com wouldn't work.  Thanks to the fine experts at Experts-Exchange, that is working now.

However, email addresses like my.email75@gmail.com or myemail.11@gmail.com don't work.  Here's my expression & the function i'm using:

function regIsEmail(fData){ 
 				
				var reg = new RegExp("^[0-9a-zA-Z\_]+@[0-9a-zA-Z]+[\.]{1}[0-9a-zA-Z]+[\.]?[0-9a-zA-Z]+$");
				return reg.test(fData); 
	}

Open in new window


To me it looks like it's allowing numbers - so I'm not sure  what needs to be changed.  Any suggestions?
0
Comment
Question by:slightlyoff
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 41759541
I'd go here to find an email validation regex. There are loads:

http://www.regexlib.com/RETester.aspx?regexp_id=26
0
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 41759614
Try:

function regIsEmail(fData){ 
 				
				var reg = new RegExp("^[0-9a-zA-Z\_]+ (?:\.[0-9a-zA-Z\_-]+)*@[0-9a-zA-Z]+[\.]{1}[0-9a-zA-Z]+[\.]?[0-9a-zA-Z]+$");
				return reg.test(fData); 
	}

Open in new window

0
 
LVL 1

Author Closing Comment

by:slightlyoff
ID: 41759712
Thank you for your help!  that worked great!
0
 
LVL 1

Author Comment

by:slightlyoff
ID: 41759714
Thank you Lee - I did go there, but finding an expression that had all the components was difficult.  now that people can make email addresses like my_name.75@gmail.co.uk it's getting kind of crazy out there...
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whatever be the reason, if you are working on web development side,  you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question