Jump to content
Larry Ullman's Book Forums

Chp14, Email Address Validation, Not Allow Starting Period(S), P.445


Recommended Posts

Hi Larry,

 

Your pattern ^[\w.-]+@[\w.-]+\.[A-Za-z]{2,6}$ provides for reasonably good email validation. However, your tip #2 warns that it will allow some invalid addresses to pass through (like ones starting with a period or containing multiple periods together). So, can I eliminate this by going with the word boundaries like this: \b[\w.-]+@[\w.-]+.[A-Za-z]{2,6}\b

 

If you, and other forum participants, also find it 'not good at all' or 'worse than the original one', please share your ideas and reasons as I really want to strive for the better one for it.

 

Thanks in advance.

 

Eric

Link to post
Share on other sites

Thanks, Eric. To be frank, when I need to validate email addresses, I use the Filter extension. I use an email address as an example in the book, as it's a good teaching example. So if you want to try to make a better email pattern, that's all good and fine, but if your goal is to do a better job validating email addresses, then you using use Filter. 

Link to post
Share on other sites

To discuss further away from the topic and the book's content, but in the same area, I happened to see this website: http://tools.email-checker.com/

 

Do you think that PHP can perform the same tasks as that website does? If yes, do you have any book about this, Larry? or do you know any online resources to point to so that I can learn more and share more about it?

 

Eric

Link to post
Share on other sites

You could write that in PHP, although I've never done that nor explained it. But, really, if you're looking to validate that an email address is an actual, live, email address that the user has access to, there's only one best way to do that: send them an email that contains a link back to your site that they have to click. Even that site/approach only verifies that the email address exists. It doesn't confirm that it's the user's email address (e.g., I could provide your email address, not mine, to that site, and get a positive result) or that it's an email address the user regularly accesses. 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...