14
The input type[email]
is intended to validate whether the field is being filled with a valid email.
But several times I have gone through questioning in some projects about why this field accept some types of email 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="[email protected]" />
<input type="email" value="wallace" />
If you notice, none of the emails whose domain was without the ".com"
or ".net"
was marked as invalid.
Why does this happen?
Why the e-mail address "wallace@dominio-sem-ponto-com"
was considered valid by browser?
Is there any case where it would be valid to use a domain without the value after the point (.com
, .net
, etc.) ?
It seems that the criterion is "has arroba". I hope it is not so simple.
– user28595
And why would it be invalid without a point? I can have a bacco@localhost, what’s the problem with that? Email has nothing to do with the internet.
– Bacco
@Bacco explains this to customers :p.
– Wallace Maxters
@Wallacemaxters the best email validator is to send a token to the guy. If he received it, it is valid.
– Bacco
The sign "@", arroba, signifca "at", or "in". It is a delimiter for the user@domain. And the domain can exist without ". com" for example! You need to check the email, there is no other way to validate it efficiently.
– Gilberto B. Terra Jr.