We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,985 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

validating email address

i'm developing an app that i intend to run on a client's intranet. i want to ensure that only email addresses with the client's domain should be registered. how do i achieve this using regular expressions?

4
Contributors
4
Replies
3 Hours
Discussion Span
3 Months Ago
Last Updated
9
Views
Question
Answered
dinhunzvi
Junior Poster in Training
74 posts since Jul 2010
Reputation Points: 10
Solved Threads: 4
Skill Endorsements: 0

Are you using PHP 5.2 or above?

If so, you could use to validate the email address as a whole:
filter_var('bob@example.com', FILTER_VALIDATE_EMAIL);

And then using strpos and substr extract the domain element and do a string comparison to restrict the domain.

blocblue
Practically a Posting Shark
837 posts since Jan 2008
Reputation Points: 272
Solved Threads: 161
Skill Endorsements: 12

if you like use jquery funcution email validata . very sample just you search email validation jquery function .

lixamaga
Newbie Poster
2 posts since Feb 2013
Reputation Points: 0
Solved Threads: 2
Skill Endorsements: 0

@lixamaga it's not safe because a user can disable javascript and submit malicious data, a server side filter, as blocblue suggested, is a necessary requirement.

cereal
Veteran Poster
1,145 posts since Aug 2007
Reputation Points: 344
Solved Threads: 222
Skill Endorsements: 22
Question Answered as of 3 Months Ago by cereal, blocblue and lixamaga

thanks @blocblue, it's now working the way i want it to

dinhunzvi
Junior Poster in Training
74 posts since Jul 2010
Reputation Points: 10
Solved Threads: 4
Skill Endorsements: 0

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0676 seconds using 2.69MB