jQuery控制输入框只能输入数值的小例子

2020-05-22 15:57:21易采站长站整理

            //失去焦点是触发
            $(“#Score”).bind(“blur”, function(event) {
                var value = $(this).val(), reg = /.$/;
                if (reg.test(value)) {
                    value = value.replace(reg, “”);
                    $(this).val(value);
                }
            })
        });
    </script>
    <body>
        <input type=”text” id=”Score” />
    </body>
</html>