Skip to content

Do not display 0 #3434

Answered by johnrom
beagle-elgaeb asked this question in Q&A
Dec 10, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Number inputs should be typed "" | number. That is, empty should be a possible value (whether or not it validates is another question).

A user might actually input "0", so that should generally be distinguishable from an empty input, plus an input populated with 0 makes it harder to enter the first number (you cannot click the input and type "1", you must double click it or press delete and then type 1).

If you're accepting "" and want it cast to 0, you can do something like:

onSubmit={values => {
  submit(values.numInput || 0);
}}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@beagle-elgaeb
Comment options

Answer selected by beagle-elgaeb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants