vector
vector

Reputation: 7576

html5 : numeric input type

I've noticed something interesting in the ways FF and Chrome treat numeric input type. If I have a value of 12.23 Chrome complains about invalid input, but FF7 is fine with that. Chrome will only accept it if I change it to 12, or change the input type to text. Is that the 'normal' behavior of Chrome in regard to numeric input type? This occurs with the latest Chrome on Ubuntu 10.10

Upvotes: 0

Views: 878

Answers (1)

robertc
robertc

Reputation: 75777

Firefox hasn't yet implemented number, so it's reporting that it's fine because it's validating as a text field.

Chrome has implemented number, and the default step for a number input is 1, therefore only whole numbers are valid. Your value isn't a whole number, so you need to explicitly set the step:

<input type="number" value="12.23" step="0.001">

Here's an example.

Upvotes: 1

Related Questions