Email Validation in AngularJS

Last Reply 7 months ago By dharmendr

Posted 7 months ago

How to validate email address in angularjs

Posted 7 months ago Modified on 7 months 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>