码迷,mamicode.com
首页 > 其他好文 > 详细

Text box to accept only number

时间:2015-03-04 14:37:34      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:

head  runat="server">

    <title></title>

    <script language="javascript" type="text/javascript">

        function CheckNumeric(e) { 

            if (window.event) // IE

            {

                if ((e.keyCode < 48 || e.keyCode > 57) & e.keyCode != 8) {

                    event.returnValue = false;

                    return false; 

                }

            }

            else { // Fire Fox

                if ((e.which < 48 || e.which > 57) & e.which != 8) {

                    e.preventDefault();

                    return false;

                 }

            }

        }    

    </script>

</head>

<body>

    <form id="form1" runat="server">

    <asp:textbox id="TextBox1" runat="server" onkeypress="CheckNumeric(event);"

             xmlns:asp="#unknown"></asp:textbox>

    </form>

</body></head>

 

http://www.codeproject.com/Tips/306192/Text-box-to-accept-only-number

Text box to accept only number

标签:

原文地址:http://www.cnblogs.com/nuaaydh/p/4313181.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!