Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #28381 > unrolled thread
| Started by | ashokacharya1988@gmail.com |
|---|---|
| First post | 2015-07-11 20:55 -0700 |
| Last post | 2015-07-14 16:38 +0200 |
| Articles | 7 — 6 participants |
Back to article view | Back to comp.lang.javascript
Regular expression for email or mobile number in one field like facebook email/mobile field in registration ashokacharya1988@gmail.com - 2015-07-11 20:55 -0700
Re: Regular expression for email or mobile number in one field like facebook email/mobile field in registration "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-07-12 11:07 +0200
Re: Regular expression for email or mobile number in one field like facebook email/mobile field in registration Steven D'Aprano <steve@pearwood.info> - 2015-07-12 22:05 +1000
Re: Regular expression for email or mobile number in one field like facebook email/mobile field in registration Dr J R Stockton <reply1500@merlyn.demon.co.uk.invalid> - 2015-07-13 23:13 +0100
Re: Regular expression for email or mobile number in one field like facebook email/mobile field in registration Steven D'Aprano <steve@pearwood.info> - 2015-07-14 12:47 +1000
Re: Regular expression for email or mobile number in one field like facebook email/mobile field in registration Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-07-13 16:50 -0300
Re: Regular expression for email or mobile number in one field like facebook email/mobile field in registration Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-14 16:38 +0200
| From | ashokacharya1988@gmail.com |
|---|---|
| Date | 2015-07-11 20:55 -0700 |
| Subject | Regular expression for email or mobile number in one field like facebook email/mobile field in registration |
| Message-ID | <9b0a260a-6988-469c-9f5a-aa738b847527@googlegroups.com> |
Regular expression for email or mobile number in one field like facebook email/mobile field in registration I am building a registration form in in which i am trying a make a field say email/mobile where user can either put email address or mobile number with country code.similiar approach is used in facebook registration.can anyone have solution for such regular expression. i am building the form using angularjs with its default validator.
[toc] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2015-07-12 11:07 +0200 |
| Message-ID | <XnsA4D571206DC84eejj99@194.109.6.166> |
| In reply to | #28381 |
ashokacharya1988@gmail.com wrote on 12 Jul 2015 in comp.lang.javascript: > > Regular expression for email or mobile number in one field like facebook > email/mobile field in registration I am building a registration form in > in which i am trying a make a field say email/mobile where user can > either put email address or mobile number with country code.similiar > approach is used in facebook registration.can anyone have solution for > such regular expression. i am building the form using angularjs with its > default validator. > Show us what you have done so far. This is not a helpdesk you order your free programming, nor are we in general interested in the internals of Facebook. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve@pearwood.info> |
|---|---|
| Date | 2015-07-12 22:05 +1000 |
| Message-ID | <55a2580f$0$1638$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #28381 |
On Sun, 12 Jul 2015 01:55 pm, ashokacharya1988@gmail.com wrote: > > Regular expression for email or mobile number in one field You *cannot* validate email addresses with a regular expression. If you try, you will just reject valid email addresses and accept invalid ones. The spec for valid email addresses is FORTY SEVEN pages long. And, even if you validate that the address is *syntactically* valid, you still have no idea whether it actually accepts mail or not. The only way to tell if an address is valid is to send email to it. I am sick and tired of websites that "helpfully" tell me that my email address, which I use to send and receive hundreds of emails every day, is not valid. If you try to validate an email address, STOP, you're doing it wrong. http://davidcel.is/posts/stop-validating-email-addresses-with-regex/ http://www.mdswanson.com/blog/2013/10/14/how-not-to-validate-email-addresses.html -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Dr J R Stockton <reply1500@merlyn.demon.co.uk.invalid> |
|---|---|
| Date | 2015-07-13 23:13 +0100 |
| Message-ID | <iBCwL1EmgDpVFwS2@invalid.uk.co.demon.merlyn.invalid> |
| In reply to | #28383 |
In comp.lang.javascript message <55a2580f$0$1638$c3e8da3$5496439d@news.a
straweb.com>, Sun, 12 Jul 2015 22:05:36, Steven D'Aprano
<steve@pearwood.info> posted:
>On Sun, 12 Jul 2015 01:55 pm, ashokacharya1988@gmail.com wrote:
>
>>
>> Regular expression for email or mobile number in one field
>
>You *cannot* validate email addresses with a regular expression. If you try,
>you will just reject valid email addresses and accept invalid ones.
>
>The spec for valid email addresses is FORTY SEVEN pages long. And, even if
>you validate that the address is *syntactically* valid, you still have no
>idea whether it actually accepts mail or not. The only way to tell if an
>address is valid is to send email to it.
>
>I am sick and tired of websites that "helpfully" tell me that my email
>address, which I use to send and receive hundreds of emails every day, is
>not valid. If you try to validate an email address, STOP, you're doing it
>wrong.
>
>http://davidcel.is/posts/stop-validating-email-addresses-with-regex/
>
>http://www.mdswanson.com/blog/2013/10/14/how-not-to-validate-email-
>addresses.html
One cannot validate a mobile number fully with a RegExp either.
One can check for an attempted E-mail address. From memory, check for
yourself, all are of the form
something only-@ something dot something
and anything else _must_ be wrong.
--
(c) John Stockton, Surrey, UK. ¬@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve@pearwood.info> |
|---|---|
| Date | 2015-07-14 12:47 +1000 |
| Message-ID | <55a47843$0$1645$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #28386 |
On Tue, 14 Jul 2015 08:13 am, Dr J R Stockton wrote: > One can check for an attempted E-mail address. From memory, check for > yourself, all are of the form > something only-@ something dot something > and anything else _must_ be wrong. Local email addresses don't even require a @ sign, so if your app is on an intranet you might have valid addresses like support helpdesk but let's assume you're on the internet so there must be at least one @. Yes, I said *at least one*, not exactly one. Does there need to be a dot after the @ sign? NO no no no. user@com user@localserver user@[IPv6:2001:db8::1] are all syntactically valid email addresses. Now that there are a whole lot more top level domains possible than just .com and .org, you could have: fred@accountants 1234567@international -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Joao Rodrigues <groups_jr-1@yahoo.com.br> |
|---|---|
| Date | 2015-07-13 16:50 -0300 |
| Message-ID | <mo14qf$8mk$1@speranza.aioe.org> |
| In reply to | #28381 |
On 12-07-2015 00:55, ashokacharya1988@gmail.com wrote: > > Regular expression for email or mobile number in one field like > facebook email/mobile field in registration I am building a > registration form in in which i am trying a make a field say > email/mobile where user can either put email address or mobile > number with country code.similiar approach is used in facebook > registration.can anyone have solution for such regular expression. i > am building the form using angularjs with its default validator. > You may try the HTML5 input type=email [1] which has good support by modern browsers [2]. Also, check out an example Regex by Cody Lindley at debuggex [3]. [1] <http://www.w3.org/TR/2014/CR-html5-20140204/forms.html#e-mail-state-(type=email)> [2] <http://caniuse.com/#feat=forms> [3] <https://www.debuggex.com/r/kk8zYcDftYnJawLR> -- Joao Rodrigues
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2015-07-14 16:38 +0200 |
| Message-ID | <2895053.KgIPk0JqQz@PointedEars.de> |
| In reply to | #28385 |
Joao Rodrigues wrote: > On 12-07-2015 00:55, ashokacharya1988@gmail.com wrote: >> Regular expression for email or mobile number in one field like >> facebook email/mobile field in registration It does not make sense to repeat the subject line verbatim in the message body. >> I am building a registration form in in which i am trying a make a field >> say email/mobile where user can either put email address or mobile >> number with country code.similiar approach is used in facebook >> registration.can anyone have solution for such regular expression. i >> am building the form using angularjs with its default validator. > > You may try the HTML5 input type=email [1] which has good support by > modern browsers [2]. > > Also, check out an example Regex by Cody Lindley at debuggex [3]. Lindley’s expression is insufficient, not least because of new TLDs [1]. The HTML5 Specification has a better expression in the referred section insofar that it supports those; however, it does not support IDNs which should be encoded with Punycode by the HTTP client, not the user [2]. However, you have overlooked that the OP is using AngularJS, and had they googled for “angular e-mail” they would have found the proper solution for them already. Of course, it will be difficult to have the *same* input field for an e-mail address *or* a mobile phone number *and* properly validate either. An e- mail address is not a valid phone number and vice-versa; and phone numbers cannot be properly validated in an international context, which means they cannot be properly recognized, which means that they cannot be told from an invalid e-mail address. [1] <http://newgtlds.icann.org/en/program-status/delegated-strings> [2] <https://en.wikipedia.org/wiki/Internationalized_domain_name> -- PointedEars FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/> Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix> Please do not cc me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web