Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #23864
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Check an input field type='email' has validated successfully |
| Date | 2014-04-11 22:51 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <li9rls$51b$1@dont-email.me> (permalink) |
| References | <d72788d9-2a59-4d3a-b5d2-24aebc9abbec@googlegroups.com> <li7058$pe5$5@dont-email.me> <lvppknnahf.fsf@saunalahti.fi> |
On Fri, 11 Apr 2014 18:37:16 +0300, Jukka Lahtinen wrote: > Denis McMahon <denismfmcmahon@gmail.com> writes: > >> The best easy check in javascript is probably that the email address >> given contains no spaces, one and only one "@" symbol, and at least one >> period on the right hand side of the "@". You can get more complex, the >> more complex you get the higher the risk of rejecting a valid email > > I think it's also safe to check that there is at least one alphanumeric > character before the @, at least one more between the @ and the last > period, and at least two after the last period. > Anything stricter than that will probably reject some valid addresses. For some value of "alphanumeric" in the context of domains being registered in non-latin alphabets. Added to which, you still have the problem that you can only check it looks like what you think a valid email address looks like, you have no guarantee that the email address entered by any visitor to a web page is one that will reach them. Unless you're going to perform some round trip verification of an email address (ie send a "create a user account" token) then you're wasting your time trying to "validate" email addresses in the browser client side, because all such "validation" will prove is "it looks right", and the more complex you make your "validation", the higher the risk of a false negative. Forms requiring the user to enter their email address twice are just as bad. Entering the same data item twice in a form is just an inconvenience for the user, and does nothing to increase the validity of the entered data. An exception may be made for passwords which are not displayed back to the user, and where it is useful to check that the user entered what they thought they entered. However, if you also have an email address for the user, and have a provision for password recovery via email, then you can possibly skip with that inconvenience as well. If I need the email address a user, then I use that email address they enter to send a token that they can use to gain access to whatever features I'm providing in return for their registering their email address. If I don't need their email address, then I don't need to capture it at all, so I don't ask for it and I don't need to worry about verifying it. So next time you're designing a form that asks for an email address, ask yourself: a) Do I need to collect this email address? b) Do I need to validate it as the user's real email address? If the answer to b is no, then the answer to a is no. If the answer to b is yes, then you need to use the supplied email address to send an email to the user containing some token which they then use to gain access to your website features / validate their account. There is no other way to validate that the email address supplied is both genuine and a valid way to communicate with the person submitting it. Note - I also expect my emailed token to be presented in the same browser session as the email address was submitted, otherwise you start again. -- Denis McMahon, denismfmcmahon@gmail.com
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Check an input field type='email' has validated successfully anthony.glazebrook@gmail.com - 2014-04-10 10:29 -0700
Re: Check an input field type='email' has validated successfully "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-04-10 20:24 +0200
Re: Check an input field type='email' has validated successfully Denis McMahon <denismfmcmahon@gmail.com> - 2014-04-10 20:49 +0000
Re: Check an input field type='email' has validated successfully Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2014-04-11 18:37 +0300
Re: Check an input field type='email' has validated successfully Christoph Michael Becker <cmbecker69@arcor.de> - 2014-04-11 18:12 +0200
Re: Check an input field type='email' has validated successfully Denis McMahon <denismfmcmahon@gmail.com> - 2014-04-11 22:51 +0000
Re: Check an input field type='email' has validated successfully Andreas Bergmaier <andber93@web.de> - 2014-04-11 01:29 +0200
Re: Check an input field type='email' has validated successfully "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-04-11 09:01 +0200
Re: Check an input field type='email' has validated successfully Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-04-11 11:02 +0200
Re: Check an input field type='email' has validated successfully Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-04-11 11:48 +0200
csiph-web