Home > DeveloperSection > Forums > How to Validate a Phone Number in AngularJS
Ankit Singh

Total Post:341

Posted on    February-28-2016 10:30 PM

 Angular JS Angular JS 

 1 Reply(s)
 698  View(s)
Rate this:
we want to Validate a Phone Number in AngularJS. please help me.

aditya kumar Patel

Total Post:254

Posted on    February-28-2016 10:32 PM


Layout = null;


<!DOCTYPE html>




<meta name="viewport" content="width=device-width" />

<script src="~/Scripts/jquery-1.9.1.js"></script>

<script src="~/Scripts/angular.js"></script>


.error {

color: red;




var app = angular.module('myApp', []);

app.controller('mainCtrl', function ($scope) {

$scope.phoneNumbr = /^\+?\d{2}[- ]?\d{3}[- ]?\d{5}$/;




<body ng-app="myApp">

<ng-form name="myForm" ng-controller="mainCtrl">

<div><b>Enter your Phone No:</b></div>


<input type="text" placeholder="+91-xxx-xxxxx" name="phone" ng-pattern="phoneNumbr" ng-model="phone" />

<br><span class="error" ng-show="myForm.phone.$error.pattern">Please Enter vailid </span>





Don't want to miss updates? Please click the below button!

Follow MindStick