Javascript: Input Field Only Allow Numbers, Backspace and Delete

You are here

Using the following javasript in your input field it is posible to restrict the text being entered to numberic values only.

<input type="text" name="quantity[]" value="0" onkeypress="return (event.charCode == 8 || event.charCode == 46 || (event.charCode >= 48 && event.charCode <= 57")) />