Textbox Length
How can set Minimum and Maximum length to textbox either in design time or Runtime?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Riddhi ValechaPosted May 10, 2013, 9:06 AM
---------------
public const int minlen=5;
public const int maxlen=10;
if(textbox1.lenght < minlen)
{
messagebox.show("less than minimum lenght");
}
if(textbox1.lenght > maxlen)
{
messagebox.show("more than maximum lenght");
}
if(textbox1.lenght >= minlen && textbox1.lenght <= maxlen)
{
messagebox.show("proper lenght");
}
-----------
Hope this helps. Just set min and max lenght as per your requirements as constants variables.
constants variables - whose values cannot be changed.
Bineesh ViswanathPosted May 10, 2013, 4:23 AM
Jignesh TrivediPosted May 9, 2013, 8:16 AM
agree with Vulpe. thereis no property for set the minimum length of text box.
In this you can use validation control if you are working with ASP.net
please refer
http://www.daniweb.com/web-development/aspnet/threads/224762/how-to-set-the-minimum-and-maximum-lengh-of-the-textbox
hope this will help you.
VulpesPosted May 9, 2013, 6:29 AM
However, there is no corresponding MinLength property.
Ravi ShekharPosted May 9, 2013, 2:39 AM
if(textbox.text.length<5 && textbox.text.length>0)
{
// code here
}
else
{
// code here
}
regards,
ravi