I have an app written in HTML 5 with an input that looks like <input type="number" min="0" max="12">, but this doesn't validate. You can write any numeric value and it doesn't get stripped on blur. Does anyone know if this is a known issue for apps?
Now I'm validating the field in JavaScript but would like to use the HTML 5 functionality if that's possible.
Add a comment
|
1 Answer
It looks like Android only has partial support for <input type="number">. It appears to ignore the min and max attributes.
That caveat aside, I think your understanding of how these fields are treated is flawed. The browser will not strip invalid characters on your behalf. If it detects that there are values that don't match the input criteria, it may prompt the user to fix their input, but it's up to you (the app developer) to do the actual validation and/or any filtering.
Check out Dive Into HTML5's section on forms for more information.
1 Comment
Margo
In my apps the not numeric signs are striped on blur from the field automatically,that's why i expected same behavior when the number is too big/small, but that may actualy be jquery mobile functionality, not html5 funcionality. Anyways, thanks for the info, i'll stick with my java script validation then :)