3 ms·
Don't overthink it. Native HTML5 elements come with form validation and even a way to serialize (!) and submit form data w/ action and method attributes. (To im
by zelly 7y ago
Don't overthink it. Native HTML5 elements come with form validation and even a way to serialize (!) and submit form data w/ action and method attributes. (To implement the same as React components would be a 3 month project coming with a 1 GiB node_modules dir.) The only time you have to add JS bloat is for date pickers and time pickers which aren't supported on Safari yet (and you can user agent sniff for this).
Blows my mind why some people choose to adopt megabytes of dependencies when you can just write a few HTML tags and have it executed by the browser's C++ engine instead of some JavaScript nightmare.
- bernawil 7y agoPeople need way more validations than html5 elements can provide. They need CC number validation. Validations that depend on the content of sibling elements. And they need it to display in custom ways like internationalized or whatever.
- zelly 7y agoAttach event listeners and handle those parts with JS. For internationalization, template on the server side, sending a different bundle for user agents in different countries. CSS is enough to fill the gaps with other internationalization concerns like rtl. The platform provides enough to do forms. It's one of the few things the web is good at. It has been around for ages and works. I mean, what I'm using to type this is a plain HTML form. It doesn't need a massive JavaScript framework that heats up my CPU on every keystroke.
- geoquant 7y agoThank you! I don't know why ValidityState is not more popular, I was shocked to learn about it recently: https://developer.mozilla.org/en-US/docs/Web/API/ValidityState https://developer.mozilla.org/en-US/docs/Web/API/ValiditySta...