Closed Toflar closed 6 years ago
I think in most cases it even does not make sense that it's output as type="number"
because of the default rendering of this type with up/down arrows in the common browsers.
I think in most cases it even does not make sense that it's output as type="number" because of the default rendering of this type with up/down arrows in the common browsers.
That's not really a reason not to use type="number"
? ;) You should always use the most specific semantics for your form fields. Just makes things easier for everyone (in theory).
Sure. The problem is the semantics: something can be a number but incrementing it does not necessarily make sense. I'd rather allow the type and pattern to be specified in the backend instead of hiding it under validation.
Sure. The problem is the semantics: something can be a number but incrementing it does not necessarily make sense.
That does not really matter as there is nothing else in the HTML5 specifications that would be suitable (yet). The front end should definitely use type="number"
. Not only does it provide a suitable HTML5 validation, but it also provides mobile users with a better user experience, since most mobile browsers will show the user a number keyboard by default for such types of inputs. The stepper on desktop browsers is just a nuisance.
Closed in favor of https://github.com/contao/contao/pull/25.
When you use a
text
form field and you set the validation tonumeric characters
(digit
), you'll get an<input type="number">
field. For those fields themaxlength
attribute is ignored (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input#attr-maxlength) so it makes no sense to configure this. Instead, for this validation,max
andmin
and evenpattern
would make sense.