Email Validation in AngularJS

Last Reply one year ago By dharmendr

Posted one year ago

How to validate email address in angularjs

Posted one year ago Modified on one year ago

Hi rani,

Check this example. Now please take its reference and correct your code.


<script type="text/javascript" src=""></script>
<script type="text/javascript">
    var app = angular.module('MyApp', []);
    app.controller('MyController', function ($scope) { });
<div ng-app="MyApp" ng-controller="MyController">
    <form name="myForm">
    Email:<input type="text" name="email" ng-model="txtEmail" ng-pattern="/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/" />
    <span style="color: Red" ng-show="$dirty &&$error.pattern">Invalid email address.</span>