Also, there is the setting of HTTP headers which requires JavaScript.
<input type="hidden" name="_method" value="PATCH">The server has to support it.
Since any sane application revalidates the response on the server anyway, client side validation is just a gimmick, it's not necessary.
We create a worse user experience by waiting until the form is submitted to inform the user of some silly error.
For some applications, the difference isn't that big, but for many it brings a significant improvement.
Is it possible to create crappy client side validation? E.g. not letting the user temporarily input invalid data while filling out the form, or displaying over-the-top red error indicators everywhere as soon as a single mistake is made, etc... Definitely. But let's not throw the baby out with the bathwater.
The backend should never trust the client, of course. That is a separate goal of the application, however.
It absolutely shouldn't be done in Javascript only.
Server side validation requires a whole page round trip. The user will have to wait, lose their scroll position... you can't rely on client side validation only, but neither is it a gimmick.
Server-side validation relying on JavaScript. You still have to wait for the server to respond, and now you need to implement UI to tell the user something is happening in the background. But at least you can start proactively validating before the user actually submits the form, so there's that.
I always wish I could ship something like that, and it does sometimes start out that way. But it never lasts, not anywhere that cares more about UX than they care about HTML purism.
Yes, blows my mind too..