• js中限制文本框输入的字符


    <input id="JZMJ" type="text" runat="server" style=" 100px;" onkeydown="PriceCheckValue(this)" />

    <input id="LXDH" type="text" style=" 100px;" runat="server" onkeydown="CheckValue()" />

    文本框中只能输入数字和一个小数点

    function PriceCheckValue(objTR)
    {
    var txtval=objTR.value;
    var e = window.event;
    var currKey = e.keyCode;
    if ((currKey < 48 || currKey > 57) && currKey != 8 && (currKey < 96 || currKey > 105) && (currKey < 37 || currKey > 40) && currKey != 9 && currKey != 13 && currKey != 46 && currKey != 189 && currKey != 109 && currKey != 190 && currKey != 110)
    {
    e.returnValue = false;

    }
    else
    {
    if(currKey==46||currKey==9||currKey== 13||currKey == 46 ||currKey == 189 ||currKey == 109 || currKey== 190 || currKey == 110)
    {
    if(txtval.indexOf(".") != -1)
    e.returnValue = false;
    }
    }

    }
    文本框中只能输入数字
    function CheckValue(e)
    {
    var e = window.event;
    var currKey = e.keyCode;
    if ((currKey < 48 || currKey > 57) && currKey != 8 && (currKey < 96 || currKey > 105) && (currKey < 37 || currKey > 40)&& currKey != 9 )
    {
    e.returnValue = false;
    }
    }

  • 相关阅读:
    函数
    特殊集合
    集合
    数组复习
    数组
    IPython--转
    python 单例模式总结
    拼多多笔试题
    python 创建实例--待完善
    转--算法时间复杂度
  • 原文地址:https://www.cnblogs.com/lff255356/p/2746548.html
Copyright © 2020-2023  润新知