如何验证只输入文本框中的数字....而不是字母表 [英] How to give Validation to enter only numbers in Textbox.... not alphabets

查看:103
本文介绍了如何验证只输入文本框中的数字....而不是字母表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,



我正在使用asp.net c#,Sqlserver 2005.



我我的网页上有一个文本框...如何设置该文本框的验证。



我只需输入该文本框中的数字....它不应该拿字母表。



如果用户在该文本框中输入字母...它必须显示一条消息。请输入数字。



请告诉我,



谢谢。

Dear Friends,

am working on asp.net c#, Sqlserver 2005.

I have a textbox on my webpage...How to Set the validation for that Textbox.

I need to enter only numbers in that textbox....it should not take alphabets.

If the user enters alphabets in that textbox...it must show a message. Please enter only numbers.

Please show me,

Thanks.

推荐答案

试试这个..



仅接受数字的文本框 [ ^ ]
Try this..

Text box to accept only number[^]


试试这个:

Try this:
void NumberValidation(object sender, KeyPressEventArgs e)
        {
            if ((e.KeyChar >= 48 && e.KeyChar <= 57) || e.KeyChar == 8)
            {
                e.Handled = false;
            }
            else
            {
                e.Handled = true;
            }
        }


还可以通过以下链接:



http://techo.luefher .com / coding / javascript-js / how-to-allow-only-numbers-in-html-textbox-using-javascript / [ ^ ]

http://csharpdotnetfreak.blogspot.com/2011/10/numeric- number-only-textbox -javascript.html [ ^ ]
Also go through below link:

http://techo.luefher.com/coding/javascript-js/how-to-allow-only-numbers-in-html-textbox-using-javascript/[^]
http://csharpdotnetfreak.blogspot.com/2011/10/numeric-number-only-textbox-javascript.html[^]


这篇关于如何验证只输入文本框中的数字....而不是字母表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆