Live data from Hacker News

Substituting JavaScript with HTML

codementor.io

11–20 of 42 posts

Re: Substituting JavaScript with HTML

#14
post #12

Coolest thing is: You can do completely without JS: Browser handles sending, backend handles processing. Yes, blows my mind too..

I was thinking this too. Forms never _needed_ Javascript to post. It's always worked this way. Am I missing something?

Form validation.

Re: Substituting JavaScript with HTML

#16
post #12

Coolest thing is: You can do completely without JS: Browser handles sending, backend handles processing. Yes, blows my mind too..

I was thinking this too. Forms never _needed_ Javascript to post. It's always worked this way. Am I missing something?

Alternative HTTP methods (only GET and POST are supported in HTML forms).

Also, there is the setting of HTTP headers which requires JavaScript.

Re: Substituting JavaScript with HTML

#17
post #7

It seems as if the author is on the way to rediscovering the idea of Unobtrusive JavaScript, aka the RSJS pattern (Reasonable System for JavaScript): http://ricostacruz.com/rsjs/ The main difference is that Unobtrusive JavaScript relies on HTML5 data attributes rather than misusing CSS classes. Perhaps the most well-known example of the Unobtrusive JavaScript approach are the AJAX helpers of Rails: http://guides.ruby…

The article mentions Unobtrusive JavaScript toward the end:

"With the addition of classes I can enjoy all the custom CSS Bootstrap provides for the most part of what we need as far as styling goes . Why can’t we have same for JS ? It turns out we actually do and such libraries are known as UnObstrusive JS libs."

Re: Substituting JavaScript with HTML

#18
post #16
post #12

Earlier quoted context omitted.

I was thinking this too. Forms never _needed_ Javascript to post. It's always worked this way. Am I missing something?

Alternative HTTP methods (only GET and POST are supported in HTML forms). Also, there is the setting of HTTP headers which requires JavaScript.

I just use a hidden field to handle that.

  

Re: Substituting JavaScript with HTML

#19
post #14
post #12

Earlier quoted context omitted.

I was thinking this too. Forms never _needed_ Javascript to post. It's always worked this way. Am I missing something?

Form validation.

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

#20
post #19
post #14

Earlier quoted context omitted.

Form validation.

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.

Validation on the client is to catch user mistakes, validation on the server is to catch malicious actors.
Post reply on HN