News for hackers. Stuff that matters.
Re:Substituting JavaScript with HTML by GoToRO on Saturday October 14, 2017 @04:44PM (#15474178)
Form validation.
Re:Substituting JavaScript with HTML by krapp on Saturday October 14, 2017 @05:42PM (#15474491)
Form validation doesn't need to be done in Javascript. I'd argue that it shouldn't ever be done in Javascript, because that means implicitly trusting the client, which is always a bad idea.

Since any sane application revalidates the response on the server anyway, client side validation is just a gimmick, it's not necessary.

Re:Substituting JavaScript with HTML by dwaltrip on Saturday October 14, 2017 @06:16PM (#15474633)
It creates a better user experience.

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.

Re:Substituting JavaScript with HTML by Spivak on Saturday October 14, 2017 @05:56PM (#15474557)
Validation on the client is to catch user mistakes, validation on the server is to catch malicious actors.
Re:Substituting JavaScript with HTML by Kuraj on Saturday October 14, 2017 @06:52PM (#15474757)
> I'd argue that it shouldn't ever be done in Javascript, because that means implicitly trusting the client, which is always a bad idea.

It absolutely shouldn't be done in Javascript only.

Re:Substituting JavaScript with HTML by untog on Saturday October 14, 2017 @07:00PM (#15474792)
> client side validation is just a gimmick

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.

Re:Substituting JavaScript with HTML by studio_monolith on Saturday October 14, 2017 @11:42PM (#15475766)
What is ajax
Re:Substituting JavaScript with HTML by Zecc on Sunday October 15, 2017 @12:25AM (#15475885)
> What is ajax

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.

Re:Substituting JavaScript with HTML by linopolus on Sunday October 15, 2017 @01:29AM (#15476045)
In special cases, maybe. Basic validation (Email looks like email, number contains no text...) is done by the browser automatically if you use semantically correct <input> types: http://diveintohtml5.info/forms.html#validation
Re:Substituting JavaScript with HTML by obilgic on Saturday October 14, 2017 @04:50PM (#15474216)
Plus dynamic fields, options