input number max length code example
Example 1: input max length
<input maxlength="10" />
Example 2: html input max vs maxlength
<input type="text" maxlength="4"/>
Example 3: dont allow user to insert number greater than particular number
function isNumberKey(e) {
var currentChar = parseInt(String.fromCharCode(e.keyCode), 10);
if(!isNaN(currentChar)){
var nextValue = $("#txthour").val() + currentChar; //It's a string concatenation, not an addition
if(parseInt(nextValue, 10) <= 12) return true;
}
return false;
}