Logo Questions Linux Laravel Mysql Ubuntu Git Menu

Validation for email or phone number for same text field in 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.

I have validations for both, with different text fields, with ng-pattern. But how can I validate for both in one text field?

I have updated my code, here:- enter code here http://plnkr.co/edit/mCVxHxl2DIvqOYtVapRN?p=preview

like image 372
kishan kurivella Avatar asked Mar 14 '23 16:03

kishan kurivella

1 Answers

Use /^([_a-z0-9]+(\.[_a-z0-9]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,5}))|(\d+$)$/


like image 104
Shamal Perera Avatar answered Apr 25 '23 07:04

Shamal Perera