📜  不允许用户插入大于特定数字的数字 - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:30.049000             🧑  作者: Mango

代码示例1
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;
}