验证 angularjs 中相同文本字段的电子邮件或电话号码 [英] Validation for email or phone number for same text field in angularjs
本文介绍了验证 angularjs 中相同文本字段的电子邮件或电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为我在 AngularJs 中的项目编写注册表.用户可以使用他/她的电子邮件/电话进行注册.我需要验证那个特定的文本框.
I am working on registration form for my project in AngularJs. Users can register with his/her Email/Phone. I need to validate that particular text-box.
我对两者都有验证,使用不同的文本字段,使用 ng-pattern.但是如何在一个文本字段中同时验证两者?
I have validations for both, with different text fields, with ng-pattern. But how can I validate for both in one text field?
我在这里更新了我的代码:- 在此处输入代码
http://plnkr.co/edit/mCVxHxl2DIvqOYtVapRN?p=preview
I have updated my code, here:- enter code here
http://plnkr.co/edit/mCVxHxl2DIvqOYtVapRN?p=preview
推荐答案
使用 /^([_a-z0-9]+(\.[_a-z0-9]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[az]{2,5}))|(\d+$)$/
这篇关于验证 angularjs 中相同文本字段的电子邮件或电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文