"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Sunday, August 29, 2010

set Minimum lenght on textbox value

 we can set maxlength of the Textbox to "n" which limits the text to be "n"
characters long.but for Minimum, we can easily do with Regex Validator
with validation Expression

Toset maxlenght
 <asp:TextBox ID="textbox1" runat="server" MaxLength="6"></asp:TextBox>
Toset Minimum Lenght
<asp:TextBox ID="textbox1" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
ValidationExpression="^[0-9]{13,16}$" runat="server"
ControlToValidate="textbox1" ErrorMessage="error">
</asp:RegularExpressionValidator> 
 
here ValidationExpression="^[0-9]{13,16}$" is the sole part.
This will accept only number and also it should have a minimum 
lenght 13 number and maxmium  length 16. 
 
i think this helped u someways. 
 
Have a nice day... 'N happy Coding :)

No comments: