Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I ran into an annoying limitation of number inputs. I want to create an input where users can step up or down by 0.5 at a time. And I want to make it so that if the number starts out as something that does not divide by 0.5, clicking the step buttons will first round up or down to the nearest multiple of 0.5. Well tough luck, that's not possible. If the number input starts with the value 0.01 and a step of 0.5, then 0.0 and 0.5 are not valid inputs, -0.49 and 0.51 are. And if I instead change the step to 0.01 to make sure 0.0 and 0.5 even become valid inputs, then the steps are super small and inconvenient for my use case, basically forcing the user to type the number instead of using the step buttons.


I had a similar issue sometime when I wanted the field to increment in powers of 2 (2, 4, 8, 16, 32, etc). I think the best way to go about it is to create custom spinner buttons which increments and decrements according to your rules, and then use the constraint validation api to set the more restrictive validity if the user inputs a value using the keyboard.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: