-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
input[type=number] should allow its value to be set to the empty string, but not all browsers (Webkit) allow that behavior #171
Comments
here's a testcase of that issue by alex sexton: it's a webkit bug. empty value should be allowed as a value as long as the |
Here's a slightly modified one: I was adding the object in the wrong place and duping a test. They both work, but this one should be better. Just include it right after modernizr. The only way to clear the input seems to be to grab it's ids and classes, completely destroy the element, and then recreate another in its place with the same id and classes. Alternatively, this issue only seems to arise when the value is set in the html initially (as in, the element was parsed with a value in the value attribute). Another option would be to potentially set a data- attribute of the values when you output the html, and then have javascript set the value on all inputs.
would turn into
Since those values would have been set dynamically, they should still be reset-able. All to say... this probably doesn't belong in Modernizr proper, since it mostly supports number and all this code would be bloat for the majority, but it really should get fixed in webkit. |
This goes far beyond was I was thinking, anyhow. I was just thinking that modernizr should allow me to check to see if clearing a number field is supported. Nothing more. Right now I added a workaround to my site, but I'd like to only add the workaround if it's necessary. |
The additional script in the jsbin link does exactly what you said there: check to see if clearing a number field is supported. The other stuff on what to do when you find out that it's not was just some helpful stuff that I picked up along the way. Feel free to ignore it. Here's the patch to add support for testing a cleared number, in case you're not a fan of jsbin:
This would put an object in Best of luck. |
We came across this issue as well so would like to leave a comment in case others out there are having the same issue as well. Try setting the value of the element to undefined! It worked for us: (the hrs and mins elements are html inputs that are of type=number) |
According to the spec, "When an
input
element'stype
attribute is in theNumber
state, ...User agents should allow the user to set thevalue
to the empty string." However, I just tried this out in Chrome 10 and that isn't supported. The value I just deleted pops back in.You may want to look into putting in a check for this. I'd find it useful, but it's not a big deal. Sorry I don't have time to help out with it!
The text was updated successfully, but these errors were encountered: