HTML number input step without validation

In HTML, you can add an attribute step

to type number inputs. I wanted this because I liked how it can make the input easier for the user by just pressing the up / down key.

I found out that an additional feature of this attribute is that it forces the user to stay within that interval. HTML does this with validation. You can enter any value manually, but it will prevent you from submitting the form. I do not want it!

To get around this, I found that there is an attribute novalidate

that is used in the tag <form>

that works great. Unfortunately, browser support is poor.

My guess is that I need to remove the attribute step

and write the function myself using JavaScript / jQuery by triggering a keydown event on it.

+3


source to share


1 answer


Unfortunately, browser support is poor.



This is not true. According to MDN, IE supports the attribute novalidate

since version 10 and input[type=number]

also since version 10. This means that if the browser supports numeric inputs, it most likely supports the attribute as well novalidate

.

+1


source







All Articles