Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Regular expression for email or mobile number in one field like facebook email/mobile field in registration Date: Tue, 14 Jul 2015 16:38:09 +0200 Organization: PointedEars Software (PES) Lines: 44 Message-ID: <2895053.KgIPk0JqQz@PointedEars.de> References: <9b0a260a-6988-469c-9f5a-aa738b847527@googlegroups.com> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1436884878 10484 eJwFwQkBwDAIA0BLpYSwyuH1L2F3phSWg0bY2p6Rr8p4oaobkaE9c6L3Tftldj4XlULAsfkDLkQR4Q== (14 Jul 2015 14:41:18 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Tue, 14 Jul 2015 14:41:18 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwNy7kBwDAIBLCVAuYd58Cw/whxqUJ6jKxdTE10dTmKKuUasUd8s3LKESVgH3UmXNJNIKnPoF/Y4WsJ5n7+AUxWFh0= Cancel-Lock: sha1:+LFpbZVXiwvNDKDM65nAGV4WNxI= X-NNTP-Posting-Host: eJwFwQkBACAIA8BK4hhiHOTpH8E7wsTyqNGUw7G5gA7Uu3uKkAcg6gQdWBnieBrcFb7S8wMcEREp Xref: csiph.com comp.lang.javascript:28413 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] [2] -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.