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

问题描述

你好,
我要验证文本框,用户仅输入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

推荐答案


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


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;
    }
};


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

05-28 06:43
查看更多