You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
When using Html.EditorFor() if the model is of type float or double we generate a input tag with type=number. Chrome does not allow decimal values in input tags of type number unless a step attribute is specified - https://code.google.com/p/chromium/issues/detail?id=74120. From the link:
According to the standard, a number with a fractional part such as 97.2 is invalid if step= attribute is not specified.
We do not generate that step attribute. We should add step=any to get it working.
However, IE allows decimal values without adding step attribute.
The text was updated successfully, but these errors were encountered:
That is an old issue (2011). Not sure if it still holds the candle as on latest Chrome (v43.0.2357.130), it accepts the decimal without step, as default value of step in IE, Chrome and Firefox is null.
However, the behavior is reproducible in IE11.
<!doctype html><html><body><formtype="post" action="https://github.com/"><inputtype="number" value="97.2" />
<inputtype="submit" />
</form><script>varelement=document.querySelector("[type=number]")alert("default value of step: "+element.getAttribute("step")+"\nvalue: "+element.value+"\nFails validation on submit in IE11")</script></body></html>
At this point I am not sure which browser is actually conforming with the standard here, but the step (with decimal like 0.3) is required in IE11.
Try entering an alphabet to trigger the real validation error on all Firefox, IE and Chrome.
If you have no step attribute, but an initial value that is a float (as above), then it will accept a float. If you have no step and no value, or an integer based value, it will not accept a float value.
FF appears to act the same.
IE11 will not accept floats unless a step value is supplied.
Spoke to @dougbu and @NTaylorMullen, we decided to use type=text for float and double types. This also maintains consistency with MVC 5 behavior. Closing this issue as this is no longer relevant.
When using
Html.EditorFor()
if the model is of typefloat
ordouble
we generate ainput
tag withtype=number
. Chrome does not allow decimal values ininput
tags of typenumber
unless astep
attribute is specified - https://code.google.com/p/chromium/issues/detail?id=74120. From the link:We do not generate that
step
attribute. We should addstep=any
to get it working.However, IE allows decimal values without adding
step
attribute.The text was updated successfully, but these errors were encountered: