If you go here, and try to input me@mail
, you will see that the directive says that the email field is valid. Why is that?
Angular Email validation with EmailValidator EmailValidator is a built-in email validator directive in Angular. It adds the email validator to controls marked with the email attribute. You can use it to perform the verification effectively.
Email can be validated using Angular PatternValidator directive with a regex. If pattern does not match, we will get validation error. In this way we can define custom email validation. For PatternValidator we need to use pattern attribute with ngModel , formControl , formControlName .
ng-valid The field content is valid. ng-invalid The field content is not valid. ng-valid-key One key for each validation. Example: ng-valid-required , useful when there are more than one thing that must be validated.
The best way to "validate" an email addresses is to simply have them type it twice and run a Regex check that gives a WARNING to the user that it doesn't look like a valid email address if it does not match the pattern, and asks the user to double check.
Domains do not need to have a dot in them. What about localhost
, e.g.?
root@localhost
is a perfectly valid email address. And if you give a name to your system (let's say, mail
), then root@mail
is valid as well. And if you also have a user me
, then me@mail
finally is valid, too.
http://en.wikipedia.org/wiki/Email_address
This wikipedia article explains thoroughly what constitutes a valid email address.
As you can see, many valid emails look very scary indeed, and probably don't pass many of the web's lesser validators.
In your case, the domain part of the email address (everything after the @), doesn't necessarily have a top-level domain. or perhaps it's entirely only a top level domain (i.e. postbox@com is valid)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With