Reputation: 2724
I've got:
<td><input type="number" min="0" style="width: 3em" data-bind="value: $data.qty" /></td>
Which accepts '-56' as number. I'd like to completely disable any other character other than numbers.
I've seen a post (Make HTML5 input type=“number” accepting dashes) which is completely the opposite of what I want.
Which kind of input type should I use, instead of having to write patterns etc?
Upvotes: 3
Views: 2230
Reputation: 2351
JS:
<input type="text" onkeypress='return event.charCode >= 48 && event.charCode <= 57'></input>
HTML 5:
<input type = "number">
Upvotes: 1