Question:
The input type[email]
is intended to validate that the field is being filled in with a valid email address.
But several times I've been questioned in some projects about why this field accepts some types of e-mail that are apparently invalid.
Example:
[type=email]:invalid{
color:red;
}
[type=email]:valid{
color: green;
border-color: lightgreen;
}
<input type="email" value="wallace@dominio-sem-ponto-com" />
<input type="email" value="wallace@xx" />
<input type="email" value="wallace@host.com" />
<input type="email" value="wallace" />
If you notice, none of the emails whose domain was without the ".com"
or ".net"
were marked as invalid.
Why does it happen?
Why was the email "wallace@dominio-sem-ponto-com"
considered valid by the browser?
Is there any case where it would be valid to use a domain without the value after the dot ( .com
, .net
, etc) ?
Answer:
validation occurs only on account of @, domain is actually a name, ex: tassio@domain , it would not necessarily need to be a sub domain (with dot), ex: tassio@mydomain.com , in what situations can this occur? Within an intranet, for example, or if Registro.br or other registry bodies release the registration of primary domains, for example, you could register a domain " google
", to access the site you would only use http://google
and an example of email would be contato@google
.