Ehsan Akbar Ehsan Akbar - 2 years ago 74
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download