Home
Tutorials
Microsoft Technologies Tutorials
Java Programming Tutorials
Web Designing Tutorials
Script Programming Tutorials
Database Programming Tutorials
Mobile Technologies Tutorials
Other Programming Tutorials
Examples
Articles
Tools
News
AngularJS ng-pattern Email Validation Example
Keywords : Angularjs email validation with ng-pattern example, Angularjs validate email id using ng-pattern example, Angularjs form validation with ngpattern example, Angularjs regex email validation
Example
<!DOCTYPE html> <html> <head> <title> AngularJs ng-pattern Email Validation Example </title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> <script type="text/javascript"> var app = angular.module('ngpatternApp', []); app.controller('ngpatternCtrl', function ($scope) { $scope.sendForm = function () { $scope.msg = "Form Validated"; }; }); </script> </head> <body> <div ng-app="ngpatternApp" ng-controller="ngpatternCtrl"> <h3>AngularJs ng-pattern Email Validation Example</h3> <form name="personForm" novalidate ng-submit="personForm.$valid &&sendForm()"> Email:<input type="text" name="email" ng-model="txtmail" ng-pattern="/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/" required /> <span style="color:Red" ng-show="personForm.email.$error.required"> Required! </span> <span style="color:Red" ng-show="personForm.email.$dirty&&personForm.email.$error.pattern">Please Enter Valid Email</span> <br /><br /> <button type="submit">Submit Form</button><br /><br /> <span>{{msg}}</span> </form> </div> </body> </html>
Click Here to See Result
Result
Previous
Next