Rigil
Rigil

Reputation: 649

Angular Email Validation

Why does Angulars' form validation always report that an email address such as a@a is valid?

I know its possible to provide a regex as a work around but I do not understand how or why Angular considers this a valid email address.

Edit: I have novalidate specified in the form tag which should bypass any html5 validation

Upvotes: 1

Views: 2392

Answers (4)

Synchro
Synchro

Reputation: 37710

There are things other than RFCs that define email addresses. In August 2013, ICANN banned the use of 'dotless' domains, with the support of just about everyone (including Microsoft, Yahoo, AOL, Apple and Google) after a long consultation. So while dotless domains in email are valid RFC822 (because they are classed as local aliases, which are not valid internet names), they are not valid to use for other reasons, and so you should indeed reject them at source, and angular is wrong to accept them.

Incidentally I wrote the HTML5 definition of email addresses with this in mind.

Upvotes: 2

Kalhan.Toress
Kalhan.Toress

Reputation: 21901

its not about angularjs validation on email. its validate by html5

<input type="email" ng-model="email" required> // this is validate by `html5` if you'r not add a custom validation to it.

difference of using novalidate. see the Plunker

first one is not using novalidate and second one is using it.

clear the input field and submit the form. the form without novalidate will show the native html5 email validation error, while form with novalidate will not showing the html5 validation error.

Upvotes: 0

user559540
user559540

Reputation:

a@a is a valid email address according to RFC 5322

Upvotes: 1

Chris Martin
Chris Martin

Reputation: 30736

Why do you think a@a is not a valid email address?

I understand the desire to check whether the domain part of an email address is a TLD, but that list is growing. So it seems unwise to build that sort of restriction into your application unless you will be diligent about keeping your TLD data up-to-date.

Upvotes: 2

Related Questions