title: How to validate email id in angularJs using ng-pattern
body: <p>Am trying to validate an Email id field in angularJs using ng-pattern directive.</p>
  
  <p>But am new to AngularJs. I need to show an error message as soon as the user enters the wrong email id.</p>
  
  <p>The code which I have below is am trying to solve. Help me out with using ng-pattern for getting the proper result.</p>
  
  <pre><code>&lt;script type="text/javascript" src="/Login/script/ang.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
      function Ctrl($scope) {
          $scope.text = 'enter email';
          $scope.word = /^[a-z]+[a-z0-9._]+@[a-z]+\.[a-z.]{2,5}$/;
      }
  &lt;/script&gt;
      &lt;/head&gt;
  &lt;body&gt;
      &lt;form name="myform" ng-controller="Ctrl"&gt;
          &lt;input type="text" ng-pattern="word" name="email"&gt;
          &lt;span class="error" ng-show="myform.email.$error.pattern"&gt;
              invalid email!
          &lt;/span&gt;
          &lt;input type="submit" value="submit"&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>