防止用户在文本框中输入值 [英] Prevent the user To Enter the values in TextBox

查看:114
本文介绍了防止用户在文本框中输入值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我要验证文本框,用户仅输入char,wild chard和integer的组合,且值不超过10位数字否.我们如何验证文本框,即所使用的类型验证.
谢谢
Arvind kumar Singh

Hello,
I want to validate the text box,the user only enter Combination of char,wild chard and integer and values is not more then 10 digit no .how we validate the text box which type validation we used..?

Thanks
Arvind kumar Singh

推荐答案

看看这个:
仅接受数字的文本框 [创建数字文本框控件 [
Have a look at this:
TextBox which accepts only numbers[^]

Creating a Numeric TextBox Control[^]

Good luck!


如果您只是想限制字符数或数字不超过10个

你可以试试这个

if you simply wants to restrict number of characters Or digit not more than 10

you can try this

<asp:TextBox ID="TextBox1" MaxLength="10" runat="server"></asp:TextBox>


重要提示!
我没有意识到ASP.Net标签!对不起!:(




限制字符串的最大长度很简单,请转到属性窗口",然后查找MaxLength属性.

IMPORTANT!!!
I didn''t realize ASP.Net tag! I''m sorry!:(




Limiting maximum length of string is simple, go to Properties Window and look for MaxLength property
or
myTextBox.MaxLength = 10; 




大多数时候,我会检查有关KeyPress事件的输入.




At most of times I check my input on KeyPress event.

myTextBox.KeyPress += delegate(object sender, KeyPressEventArgs e)
{
    if (!IsMyCharOk(e.KeyChar))
    {
        //unwanted values are handled B)
        e.Handled = true;
    }
};


这篇关于防止用户在文本框中输入值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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