5 ms·
>Really, there is no reason why a form should require JavaScript. This is one of those things that's technically true, but misleading. Without scripting, you
by ubermonkey 7y ago
>Really, there is no reason why a form should require JavaScript.
This is one of those things that's technically true, but misleading.
Without scripting, you can't do any client-side validation, so you have to submit the form.
Without scripting, it's then harder to repop the form for the user when it fails.
I'm not saying things aren't excessive today -- they clearly are. But tossing client-side scripting entirely seems like a baby/bathwater situation.
- gdfasfklshg4 7y agoYou need to re-do all your client-side user assistance prompts+ with real validation serverside anyway... + client-side validation is not validation.
- spookthesunset 7y agoServer side validation is a backstop. It doesn't need to have fancy error messages or anything like that. Client side can have friendly, nice error handling and validation. Server side can damn near barf on the user's shoes when it encounters a validation issue.
- dfox 7y agoMost forms either don't need any kind of validation or you still have to validate the data on the server and do something reasonable when it fails. Repopulating the form on the server side after validation failure is trivial and even more so when there are libraries that abstract that away (eg. wtforms). On a similar note I somehow fail to see the benefit of writing (and often duplicating) large parts of business logic in client-side javascript and replacing perfectly good HTML form-submission mechanism with random JSON "REST" APIs.
- GrinningFool 7y ago> Repopulating the form on the server side > after validation failure is trivial You'd think so, but the number of sites out there that still require me to re-type the full form because one field failed validation is mind-boggling.
- brobdingnagians 7y agoJust use Weboolkit (Wt, http://webtoolkit.eu/ http://webtoolkit.eu/). It handles graceful degredation on no-JS automatically. This is one of the neatest things about it, you get full single page interaction w/ sockets if supported, or just normal HTTP pages if Javascript is disabled or not supported.
- zeveb 7y agoYou absolutely have to do server-side validation anyway, since clients can lie. Since you're doing the server-side validation you have to do anyway, it's child's play to return the HTML form with the values the client submitted pre-filled. Client-side validation is a user convenience; it's awesome, but not sufficient in itself, because it can only protect the client, not the server, from invalid values.
- seer 7y agoHtml validation is actually quite powerful and can help with most "quality of life" validations. You know the "this field is required" or "this field needs to be a number" kind of thing. Even more, html validation has by far a much better UX than most custom made JS solutions. For example if there is an error in the validation, your cursor is immediately transported to the offending field where you can do the correction, with the appropriate css classes available to highlight the field properly. And for the stuff that html validation is not powerful enough, well then you most probably want to check that on the server as well anyway.
- wilsonrocks 7y agoHTML5 validation is excellent, even better if you use JS to customise it...
- s_y_n_t_a_x 7y agoYes you can do client-side validation. You're constrained to the pattern fields and the browser implementation, but it's enough to block most invalid submissions.