-1

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

would this code be legal:

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

and does it work in practice in different environments/browsers?

Kevin Wheeler
  • 1,331
  • 2
  • 15
  • 24

1 Answers1

1

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.

My read on that is that yes, it is okay to use an empty string.

enhzflep
  • 12,927
  • 2
  • 32
  • 51