<input class="text" name="Serial_Num" type="text" id="SrNo" size="2" maxlength="2" onkeypress="return digitKeyOnly(event)" />
Run code snippet
function digitKeyOnly(e) {
var keyCode = e.keyCode == 0 ? e.charCode : e.keyCode;
var value = Number(e.target.value + e.key) || 0;
if ((keyCode >= 37 && keyCode <= 40) || (keyCode == 8 || keyCode == 9 || keyCode == 13) || (keyCode >= 48 && keyCode <= 57)) {
return isValidNumber(value);
}
return false;
}
function isValidNumber (number) {
return (1 <= number && number <= 10 )
}