Ehsan Akbar Ehsan Akbar - 5 months ago 9
Javascript Question

ng-show="frm.Email.$ " doesn't show the error of invalid email

I am trying to create a login form in with angularjs validation ,

here is my code :

<span style="color:red" ng-show="frm.Email.$dirty || frm.Email.$invalid">
<span ng-show="frm.Email.$error.required">ایمیل را وارد کنید</span>
<span ng-show="frm.Email.$">ایمیل وارد شده نامعتبر است</span>

when i leave the textbox empty the error is appeared
but when i enter an invalid email
the error of
doesn't appear.why?


It seems you are using <input type="text">. For email, you should use <input type="email">. To validate email address, Angular use HTML5 valid and invalid controls.