Hacker News new | ask | show | jobs
by capitainenemo 1339 days ago
95% of the functionality web apps I've been put in charge of building works without JavaScript. You do lose things like form validation, and some of the links to things like detail forms opens in the same window instead. Or, say, a master/detail selection having a full list of hundreds of items instead of 90% of them hidden based on <optgroup>

It's useful for most of the reasons listed in the parent article.

You can also do quite a lot in CSS these days for interactivity - and with better performance than JS. Expand/collapse sections (with animation), menus including transition delay for more mouse forgiveness, slide out panels.. Also pretty easy to then tweak it for alternate mobile layout.

1 comments

HTML and CSS have form validation too. You can do something like :has(:valid) when you add in your validation schema in the HTML.
Yep! Regrettably the issue I had was getting JS and HTML5 form validation to work nicely together. The issue was that the HTML5 validation was triggering before the onsubmit which was when we were reviewing the entire form for consistency. So even though we played around with it, and in some places used it for "required" it just didn't work out too well with a lot of the ways we were validating forms. I'm sure we could have made it work - turning on and off the HTML5 validation as needed, using an onclick or some other event instead, but it was easier to just let the non-JS version be validated server-side (which we obviously do as well, as any sane dev would).

I am a fan of the HTML5 validation though - offered feedback when they were working on it that I think made it into the spec like interaction of required and hidden elements...

And, I suspect for most of our forms the simple patterns of HTML5 validation would be fine, it's just that sometimes it wasn't, and it was easier to be consistent in how validation worked and looked... So. Chalk it up to laziness. So long as the forms still worked we decided to let it be.