How can I validate emailid and mobile no both in a single input box in AngulaJS
?
I'm trying to validate emaild and mobile no in same input box. it is working fine seperately, but for both emaild and mobile it doesn't work.
How can I validate emailid and mobile no both in a single input box in AngulaJS
?
I'm trying to validate emaild and mobile no in same input box. it is working fine seperately, but for both emaild and mobile it doesn't work.
If you wish to verify the input using AngularJS (not the safest way to do it if it's the only check, making a second check in PHP/back-end/server side is recommanded).
You can use regular expression to filter the email and the phone number. You might want to check out ng-pattern
AngularJS Official documentation page
Emails and AngularJS: https://docs.angularjs.org/api/ng/input/input%5Bemail%5D Example: https://jsfiddle.net/txtuz2xn/4/
Phone number will vary from a country to another. Up to you to see how you want your regex to go.
If you want to have 1 input that checks either the phone or the email you could set up $scope.regex1 = ...
and $scope.regex2 = ...
and check regex2 if regex1 fails.