HTLF

一步一个脚印,走出高度...

导航

常见js方法

关于input

只限只能输入11位

  1. 行内使用
<input type="number" oninput="if(value.length>11)value=value.slice(0,11)">

2、方法调用

    <input type="text" id="inputBox" oninput="inputValLength(this)">
<script>
function inputValLength(input) {
        if (input.value.length > 11) {
        input.value = input.value.slice(0, 11);
    }
}
</script>

posted on 2024-02-02 09:32  HTLF  阅读(3)  评论(0编辑  收藏  举报