Why does “a@a” pass built-in validation for an email input? [duplicate]












1
















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?










share|improve this 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 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


















1
















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?










share|improve this 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 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
















1












1








1









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?










share|improve this question

















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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



















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














2 Answers
2






active

oldest

votes


















1














Hostnames do not have to have a domain associated with their TLD. A common example would be localhost.






share|improve this answer





















  • 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













  • Can you have an email address with only the top level domain as the domain part?

    – t.niese
    Nov 22 '18 at 0:02



















0














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.






share|improve this answer






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Hostnames do not have to have a domain associated with their TLD. A common example would be localhost.






    share|improve this answer





















    • 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













    • 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














    Hostnames do not have to have a domain associated with their TLD. A common example would be localhost.






    share|improve this answer





















    • 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













    • 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








    1







    Hostnames do not have to have a domain associated with their TLD. A common example would be localhost.






    share|improve this answer















    Hostnames do not have to have a domain associated with their TLD. A common example would be localhost.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 22 '18 at 0:01

























    answered Nov 21 '18 at 23:39









    Charles StoverCharles Stover

    83339




    83339








    • 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













    • 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





      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








    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













    0














    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.






    share|improve this answer




























      0














      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.






      share|improve this answer


























        0












        0








        0







        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.






        share|improve this answer













        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 '18 at 23:37









        BradBrad

        115k27232393




        115k27232393















            Popular posts from this blog

            Paul Cézanne

            UIScrollView CustomStickyHeader Resize height generates problems when scroll is too fast

            Angular material date-picker (MatDatepicker) auto completes the date on focus out