2010-12-07 115 views
0

我有一个供用户添加密码的文本框,我想阻止用户在文本框中添加一个字符,我该怎么做?用户名密码长度

+2

添加什么角色?如果你的意思是不允许超过x个字符,例如10,使用MaxLength属性,否则解释更好。 – 2010-12-07 13:53:44

回答

0

使用validater类似:

<asp:RangeValidator 
ControlToValidate="tbox1" 
MinimumValue="1" 
MaximumValue="100" 
Type="Integer" 
EnableClientScript="false" 
Text="The value must be from 1 to 100!" 
runat="server" /> 

<asp:RegularExpressionValidator 
ID="regexTextBox1" 
ControlToValidate="YourTextBoxID" 
runat="server" 
ValidationExpression="^[\s\S]{1,200}$" 
Text="200 characters max" />