Live data from Hacker News

HTML Form Validation is underused

expressionstatement.com

151–160 of 343 posts

Re: HTML Form Validation is underused

#151

Earlier quoted context omitted.

Most of the forms features are from the early 90s. You're not working in the same millennium as some of the specification writers.

The `required` attribute, which this article is about, is an HTML5 thing and first appeared in browsers in 2010-2011. So sure, not brand spanking new, but the web was already used to write modern apps. There's no good reason for the validation features to be so shabby.

Even 'required' doesn't work properly. Browsers do very odd and inconsistent things when your required field is hidden when submitting. Like in a basic tabbed or multi-step form.

Re: HTML Form Validation is underused

#152
post #118
post #106

Earlier quoted context omitted.

What do you mean? Most browsers support natively just fine.

On Android, the date picker widget is fiddly to use for selecting distant dates, like date of birth. Not impossible but requires many many taps.

I've never had a problem with that myself. I guess people don't know you cab tap the year in the date picker to quickly go back a bunch of years?

Re: HTML Form Validation is underused

#153
post #31

Earlier quoted context omitted.

I avoid the use of `type=number` and use `type=text inputmode=numeric` instead. It doesn't come with these arrow buttons which most users don't need anyway for entering numbers. Also the keyboard is better on iOS.

But what's crazy is both of those still don't disallow non-numeric input unless you use JS to reject keystrokes and intercept paste. HTML form validation is so incomplete and limited, every time I look at it I want to scream cause wtf there's so many just totally obvious things we need that don't exist by default and we need to reinvent the wheel. Native date and time inputs are still garbage so every UI framework ha…

You shouldn't reject keystrokes as that can lead to silent errors when the user thinks they entered something that was not allowed.

And final validation needs to happen on the server side anyway - anything before that is just a usability helper.

Re: HTML Form Validation is underused

#154
Built-in validation is pretty much the only reason I use forms.

Capturing input with frameworks is much simpler than pulling the values out of an event object, so I'd be okay with just using input and button elements.

Yet, that doesn't trigger the validation, so I end up wrapping it with a form element and using a submit button.

Re: HTML Form Validation is underused

#155

Html form validation is great. There's just one gigantic catch: It doesn't work in Firefox for Android. https://bugzilla.mozilla.org/show_bug.cgi?id=1510450

I'm using Firefox on all of my mobile devices but I can't blame devs for ignoring FF for Android on this one. This is an API every other browser had working 10 years ago, it's on the Firefox team to sort out this mess. The less than a percent of users who don't see the error messages for controls marked in red isn't worth ignoring the standard for.

The more websites use this, the more pressure Mozilla will feel to fix their browser. This isn't something like WebMIDI or whatever API Chrome or Safari implemented before standardising, it's part of the original HTML5 spec.

Re: HTML Form Validation is underused

#156

Earlier quoted context omitted.

Nah. Users are too stupid to fix their own inputs in many cases. Seen inputs with zero-width spaces that are invisible which fail validation. User doesn't understand why, complains. Enforcing a character set for certain kinds of inputs is a very good thing.

In 26 years of web dev, mostly as a frontend person, I've only seen zero width spaces in three situations - pasting from Word - QA testers being through - devs pranking each other The third one is by far the most common. Word is much better these days and I've not seen that happen in a long time. I wish I saw QA test this stuff more often. The idea that it's common enough that you'd break your UX to handle it bafflin…

I see weird spaces every time I copy-paste from some pdf pretty much, especially if it's a digitised or 10+ years one. Hardly an irrelevant use case

Re: HTML Form Validation is underused

#157

Last time I checked, web-browsers today still do not allow you to style the appearance of built-in HTML validation messages [1]; this wouldn't be so bad if Chrome (and Firefox) still conformed to their OS platform UI guidelines (i.e. so it looks system-generated, like how `title=""` tooltips used to be), instead Chrome uses this ugly yellow/orange icon color with black-text on a white background on a bubble with a fi…

True. But you can hide the default message and replace it with your own. You'll still benefit from the form validation.

You can even benefit from the default messages if you want that, grabbing `input.validationMessage` and rendering it as you wish.

Re: HTML Form Validation is underused

#158

Last time I checked, web-browsers today still do not allow you to style the appearance of built-in HTML validation messages [1]; this wouldn't be so bad if Chrome (and Firefox) still conformed to their OS platform UI guidelines (i.e. so it looks system-generated, like how `title=""` tooltips used to be), instead Chrome uses this ugly yellow/orange icon color with black-text on a white background on a bubble with a fi…

True. But you can hide the default message and replace it with your own. You'll still benefit from the form validation.

There is no real benefit because the validation rules allowed there are often too limited for real use-cases anyway.

Re: HTML Form Validation is underused

#159
post #108

Earlier quoted context omitted.

Unfortunately the number input is lacking and inconsistent. We’ve always fallen back to JavaScript validation.

https://jsfiddle.net/gaby_de_wilde/1qh4cax7/ I'm trying to picture a room full of people developers agreeing letters are numbers too! Lets give the little people a slider but lets call it a range! I really feel like they are trolling. You start with a neat database table then you engage in an endless struggle trying to allow the user to edit a single row of it. It really feels like you are not suppose to do it. As if…

They’d want 7 parallel lines, 1 red, 2 green, 2 transparent, 2 blue. Oh, and 1 of those lines should be perpendicular.

Re: HTML Form Validation is underused

#160
post #85

Here's a simple example that doesn't use React: https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectE...

I believe you could probably do most of that with just css now too. Disabling the default pop up from showing up may be the only thing you need javascript to do.
Post reply on HN