Validating email id
Any mistype will result in an invalid email address.[epiphany]Even if the sun shone through my window and I was visited by a particularly savage sneeze (I suffer from Autosomal Dominant Compelling Helio-Ophthalmic Outburst Syndrome*) and I typed out #! ^_`|[email protected] mistake, I would still pass the most thorough email ‘validation’ techniques. ^_`|[email protected] she said she gets super pissed off when told that her email address isn’t valid. For example hitting the neighbouring ‘h’ key instead of ‘g’.
(The flip side is I fail and be told my address isn’t valid when it is! She regrets buying the domain, too, but won’t give it up, just like the guy that’s got I am more likely to mis-type with a letter on the visible keyboard with no shift key required (I apply a weighting to non-modified keys in the model). So from a list of 117 million email addresses I have calculated the frequency of occurrence of each character and for each, noted which keys lie closest on the keyboard, and factored in the likelihood that a mis-stroke will create an invalid email address.
You will also never again run the risk of rejecting what is, in fact, a strange, valid email address.
The trick is to first define what we mean by ‘valid’.
The best option is to ask the user to type their e-mail in twice and if you MUST use a regex checker, then tell the user that their e-mail address does not appear to be valid and ask if they are sure they typed it right.A user is far more likely to enter a wrong and valid email address than they are to enter an invalid one. Therefore, you are better off spending your time doing literally than trying to validate email addresses. (That’s a bold full-stop for effect.)I have published a follow up to this post that looks at how to help prevent your users from entering a wrong email address in the first place. Take the Edit Text box string using get Text() and compare with pattern provided for email.If pattern doesn't match or macthes, on Click of button toast a message.