...">

Is it legal to set an input with type = number to be empty

Suppose I have <input id="inpID" type="number" min="1" max="5" value="3"></input>

will this code be legal:

$("#inpID").val('');

and does this work in practice across different environments / browsers?

-1


source to share


1 answer


Taken from here: http://www.w3.org/TR/html5/forms.html#number-state-(type=number)

If the element is mutable, the user agent should allow the user to change the number represented by its value, as obtained from applying the rules for parsing floating-point number values to it. User agents must not allow the user to set the value to a non-empty string that is not a valid floating-point number.



I've read that yes, it's okay to use an empty string.

+1


source







All Articles