zoukankan      html  css  js  c++  java
  • 文本框只能输入数字代码

    1.文本框只能输入数字代码(小数点也不能输入)
    <input onkeyup="=.replace(/\D/g,'')" onafterpaste="=.replace(/\D/g,'')">

    2.只能输入数字,能输小数点.
    <input onkeyup="if(isNaN(value))execCommand('undo')" onafterpaste="if(isNaN(value))execCommand('undo')">
    <input name=txt1 onchange="if(/\D/.test()){alert('只能输入数字');='';}">

    3.数字和小数点方法二
    <input type=text t_value="" o_value="" onkeypress="if(!.match(/^[\+\-]?\d*?\.?\d*?$/))=this.t_value;else this.t_value=;if(.match(/^(?:[\+\-]?\d+(?:\.\d+)?)?$/))this.o_value=" onkeyup="if(!.match(/^[\+\-]?\d*?\.?\d*?$/))=this.t_value;else this.t_value=;if(.match(/^(?:[\+\-]?\d+(?:\.\d+)?)?$/))this.o_value=" onblur="if(!.match(/^(?:[\+\-]?\d+(?:\.\d+)?|\.\d*?)?$/))=this.o_value;else{if(.match(/^\.\d+$/))=0+;if(.match(/^\.$/))=0;this.o_value=}">

    4.只能输入字母和汉字
    <input onkeyup="value=(/[\d]/g,'') "onbeforepaste="('text',('text').replace(/[\d]/g,''))" maxlength=10 name="Numbers">

    5.只能输入英文字母和数字,不能输入中文
    <input onkeyup="value=(/[^\w\.\/]/ig,'')">

    6.只能输入数字和英文<font color="Red">chun</font>
    <input onKeyUp="value=(/[^\d|chun]/g,'')">

    7.小数点后只能有最多两位(数字,中文都可输入),不能输入字母和运算符号:
    <input onKeyPress="if((<48 || >57) && !=46 || /\.\d\d$/.test(value))=false">

    8.小数点后只能有最多两位(数字,字母,中文都可输入),可以输入运算符号:
    <input onkeyup="=.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3')">

    ======================文本框只能输入数字及小数点=========================

       <li class="searchbox_name">主设备:</li>
                            <li class="searchbox_box">
                                <asp:TextBox ID="txtMain_Mate" runat="server"></asp:TextBox>万 </li>
                            <asp:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" FilterType="Custom"
                                ValidChars="012345689." TargetControlID="txtMain_Mate">

  • 相关阅读:
    leetcode 131. Palindrome Partitioning
    leetcode 526. Beautiful Arrangement
    poj 1852 Ants
    leetcode 1219. Path with Maximum Gold
    leetcode 66. Plus One
    leetcode 43. Multiply Strings
    pytorch中torch.narrow()函数
    pytorch中的torch.repeat()函数与numpy.tile()
    leetcode 1051. Height Checker
    leetcode 561. Array Partition I
  • 原文地址:https://www.cnblogs.com/qq1040991197/p/2714949.html
Copyright © 2011-2022 走看看