1,105,399 Community Members

validating email address

Member Avatar
dinhunzvi
Junior Poster in Training
98 posts since Jul 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 7 [?]
Skill Endorsements: 0 [?]
 
0
 

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?

Member Avatar
blocblue
Practically a Posting Shark
828 posts since Jan 2008
Reputation Points: 238 [?]
Q&As Helped to Solve: 162 [?]
Skill Endorsements: 16 [?]
Featured
 
1
 

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.

Member Avatar
lixamaga
Newbie Poster
2 posts since Feb 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
cereal
Posting Virtuoso
1,710 posts since Aug 2007
Reputation Points: 461 [?]
Q&As Helped to Solve: 345 [?]
Skill Endorsements: 44 [?]
 
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.

Question Answered as of 1 Year Ago by lixamaga, cereal and blocblue
Member Avatar
dinhunzvi
Junior Poster in Training
98 posts since Jul 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 7 [?]
Skill Endorsements: 0 [?]
 
0
 

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

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: