Why does “a@a” pass built-in validation for an email input? [duplicate]
This question already has an answer here:
Why does HTML5 form-validation allow emails without a dot?
8 answers
I created an input with the following mark-up:
<input name="contactEmail" type="email" required>
I added a CSS class for input:invalid which gives it a red border, and then tested it by inputting a@a as the value, and the field was marked valid. Why would that be a valid input for this when it's clearly not a valid email? Regarding valid values for an input of type email, MDN says:
In simple terms, this means username@domain.tld
But this obviously doesn't match any regex designed to look for that pattern. So...what gives?
Edit:
According to MDN, this is algorithm used for email validation in compliant browser:
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
I haven't broken that apart yet, but a@a does indeed match it. So I guess the question becomes why does the regex all that to match?
html html5 validation
marked as duplicate by Soufiane Hassou, temporary_user_name, Adam, Sebastian Speitel, C-Pound Guru Nov 22 '18 at 1:39
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Why does HTML5 form-validation allow emails without a dot?
8 answers
I created an input with the following mark-up:
<input name="contactEmail" type="email" required>
I added a CSS class for input:invalid which gives it a red border, and then tested it by inputting a@a as the value, and the field was marked valid. Why would that be a valid input for this when it's clearly not a valid email? Regarding valid values for an input of type email, MDN says:
In simple terms, this means username@domain.tld
But this obviously doesn't match any regex designed to look for that pattern. So...what gives?
Edit:
According to MDN, this is algorithm used for email validation in compliant browser:
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
I haven't broken that apart yet, but a@a does indeed match it. So I guess the question becomes why does the regex all that to match?
html html5 validation
marked as duplicate by Soufiane Hassou, temporary_user_name, Adam, Sebastian Speitel, C-Pound Guru Nov 22 '18 at 1:39
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Can you have an email address with only the top level domain as the domain part? and New gTLD Dotless Domain Names Prohibited. So while it is valid to havea@aaccording to the specs, it is prohibited according to the icann. But because ICANN could change its mind in future, you would develop a validator according to the specs.
– t.niese
Nov 22 '18 at 0:02
add a comment |
This question already has an answer here:
Why does HTML5 form-validation allow emails without a dot?
8 answers
I created an input with the following mark-up:
<input name="contactEmail" type="email" required>
I added a CSS class for input:invalid which gives it a red border, and then tested it by inputting a@a as the value, and the field was marked valid. Why would that be a valid input for this when it's clearly not a valid email? Regarding valid values for an input of type email, MDN says:
In simple terms, this means username@domain.tld
But this obviously doesn't match any regex designed to look for that pattern. So...what gives?
Edit:
According to MDN, this is algorithm used for email validation in compliant browser:
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
I haven't broken that apart yet, but a@a does indeed match it. So I guess the question becomes why does the regex all that to match?
html html5 validation
This question already has an answer here:
Why does HTML5 form-validation allow emails without a dot?
8 answers
I created an input with the following mark-up:
<input name="contactEmail" type="email" required>
I added a CSS class for input:invalid which gives it a red border, and then tested it by inputting a@a as the value, and the field was marked valid. Why would that be a valid input for this when it's clearly not a valid email? Regarding valid values for an input of type email, MDN says:
In simple terms, this means username@domain.tld
But this obviously doesn't match any regex designed to look for that pattern. So...what gives?
Edit:
According to MDN, this is algorithm used for email validation in compliant browser:
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
I haven't broken that apart yet, but a@a does indeed match it. So I guess the question becomes why does the regex all that to match?
This question already has an answer here:
Why does HTML5 form-validation allow emails without a dot?
8 answers
html html5 validation
html html5 validation
edited Nov 21 '18 at 23:37
temporary_user_name
asked Nov 21 '18 at 23:31
temporary_user_nametemporary_user_name
16.7k2897162
16.7k2897162
marked as duplicate by Soufiane Hassou, temporary_user_name, Adam, Sebastian Speitel, C-Pound Guru Nov 22 '18 at 1:39
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Soufiane Hassou, temporary_user_name, Adam, Sebastian Speitel, C-Pound Guru Nov 22 '18 at 1:39
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Can you have an email address with only the top level domain as the domain part? and New gTLD Dotless Domain Names Prohibited. So while it is valid to havea@aaccording to the specs, it is prohibited according to the icann. But because ICANN could change its mind in future, you would develop a validator according to the specs.
– t.niese
Nov 22 '18 at 0:02
add a comment |
Can you have an email address with only the top level domain as the domain part? and New gTLD Dotless Domain Names Prohibited. So while it is valid to havea@aaccording to the specs, it is prohibited according to the icann. But because ICANN could change its mind in future, you would develop a validator according to the specs.
– t.niese
Nov 22 '18 at 0:02
Can you have an email address with only the top level domain as the domain part? and New gTLD Dotless Domain Names Prohibited. So while it is valid to have
a@a according to the specs, it is prohibited according to the icann. But because ICANN could change its mind in future, you would develop a validator according to the specs.– t.niese
Nov 22 '18 at 0:02
Can you have an email address with only the top level domain as the domain part? and New gTLD Dotless Domain Names Prohibited. So while it is valid to have
a@a according to the specs, it is prohibited according to the icann. But because ICANN could change its mind in future, you would develop a validator according to the specs.– t.niese
Nov 22 '18 at 0:02
add a comment |
2 Answers
2
active
oldest
votes
Hostnames do not have to have a domain associated with their TLD. A common example would be localhost.
1
localhostis a TLD (rfc2606). But a TLD does not need to have the domain or subdomain part. Soa@comcould also be valid.
– t.niese
Nov 21 '18 at 23:59
Can you have an email address with only the top level domain as the domain part?
– t.niese
Nov 22 '18 at 0:02
add a comment |
There's nothing invalid about it. It's as simple as that.
There's no reason a mailbox can't be called a on the host a.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Hostnames do not have to have a domain associated with their TLD. A common example would be localhost.
1
localhostis a TLD (rfc2606). But a TLD does not need to have the domain or subdomain part. Soa@comcould also be valid.
– t.niese
Nov 21 '18 at 23:59
Can you have an email address with only the top level domain as the domain part?
– t.niese
Nov 22 '18 at 0:02
add a comment |
Hostnames do not have to have a domain associated with their TLD. A common example would be localhost.
1
localhostis a TLD (rfc2606). But a TLD does not need to have the domain or subdomain part. Soa@comcould also be valid.
– t.niese
Nov 21 '18 at 23:59
Can you have an email address with only the top level domain as the domain part?
– t.niese
Nov 22 '18 at 0:02
add a comment |
Hostnames do not have to have a domain associated with their TLD. A common example would be localhost.
Hostnames do not have to have a domain associated with their TLD. A common example would be localhost.
edited Nov 22 '18 at 0:01
answered Nov 21 '18 at 23:39
Charles StoverCharles Stover
83339
83339
1
localhostis a TLD (rfc2606). But a TLD does not need to have the domain or subdomain part. Soa@comcould also be valid.
– t.niese
Nov 21 '18 at 23:59
Can you have an email address with only the top level domain as the domain part?
– t.niese
Nov 22 '18 at 0:02
add a comment |
1
localhostis a TLD (rfc2606). But a TLD does not need to have the domain or subdomain part. Soa@comcould also be valid.
– t.niese
Nov 21 '18 at 23:59
Can you have an email address with only the top level domain as the domain part?
– t.niese
Nov 22 '18 at 0:02
1
1
localhost is a TLD (rfc2606). But a TLD does not need to have the domain or subdomain part. So a@com could also be valid.– t.niese
Nov 21 '18 at 23:59
localhost is a TLD (rfc2606). But a TLD does not need to have the domain or subdomain part. So a@com could also be valid.– t.niese
Nov 21 '18 at 23:59
Can you have an email address with only the top level domain as the domain part?
– t.niese
Nov 22 '18 at 0:02
Can you have an email address with only the top level domain as the domain part?
– t.niese
Nov 22 '18 at 0:02
add a comment |
There's nothing invalid about it. It's as simple as that.
There's no reason a mailbox can't be called a on the host a.
add a comment |
There's nothing invalid about it. It's as simple as that.
There's no reason a mailbox can't be called a on the host a.
add a comment |
There's nothing invalid about it. It's as simple as that.
There's no reason a mailbox can't be called a on the host a.
There's nothing invalid about it. It's as simple as that.
There's no reason a mailbox can't be called a on the host a.
answered Nov 21 '18 at 23:37
BradBrad
115k27232393
115k27232393
add a comment |
add a comment |
Can you have an email address with only the top level domain as the domain part? and New gTLD Dotless Domain Names Prohibited. So while it is valid to have
a@aaccording to the specs, it is prohibited according to the icann. But because ICANN could change its mind in future, you would develop a validator according to the specs.– t.niese
Nov 22 '18 at 0:02