<input type="text" maxlength="1" oninput="this.value=this.value.replace(/[^0-9]/g,'');" /> Run code snippet