[HN Gopher] HTML Form Validation is heavily underused
       ___________________________________________________________________
        
       HTML Form Validation is heavily underused
        
       Author : stereoabuse
       Score  : 4 points
       Date   : 2024-10-28 21:28 UTC (1 hours ago)
        
 (HTM) web link (expressionstatement.com)
 (TXT) w3m dump (expressionstatement.com)
        
       | joshchernoff wrote:
       | simply adding required is all you need.Not required=true The
       | omission is equal to required=false. No one really write
       | required=true, they just add the attribute `required` only by its
       | self. This is one of the odd quarks about html attrs
       | 
       | Same is true for things like disabled ect
       | https://developer.mozilla.org/en-US/docs/Glossary/Boolean/HT...
       | 
       | > The strings "true" and "false" are invalid values. To set the
       | attribute to false, the attribute should be omitted altogether.
       | Though modern browsers treat any string value as true, you should
       | not rely on that behavior.
       | 
       | in other words required=false may still end up making the field
       | required. FYI.
        
       | donatj wrote:
       | You gotta be careful about going overboard with it.
       | 
       | Recently I was trying to get a refund on Groupon because the
       | company I'd bought a Groupon for was under new management that
       | refused to honor my groupon.
       | 
       | The form had a stipulation "minimum of 15 words". Try as I might,
       | I could not get the form to pass validate until I inspected the
       | HTML.                 <input pattern="^(\b\w+\b\s*){15,}$"
       | required>            \w - word characters       \b - word
       | boundaries       \s - white
       | 
       | Literally zero allowance for any sort of punctuation.
        
       ___________________________________________________________________
       (page generated 2024-10-28 23:01 UTC)