0

Hi,

Please anyone help me out............

I want the users to enter the data in the textbox of the minimum length of "10" and maximum length can be "ANY"(or above "10").

Thanks in advance...........................

9
Contributors
9
Replies
26
Views
7 Years
Discussion Span
Last Post by Sagar_7
0

Why not just validate on the postback and come back with an error message if it is <10 characters? I can't think of any website that enforces a minimum length validation browser side.

2

You can use a RegularExpression validation for this purpose.

<asp:TextBox ID="TextBox1" runat="server"  />
<asp:RegularExpressionValidator ID="regExTextBox1" runat="server" 
   ControlToValidate="TextBox1"
   ErrorMessage="Minimum password length is 10"
   ValidationExpression=".{10}.*" />

Edited by Ramesh S: n/a

Votes + Comments
or that
0

or you could use a custom validator:

this part in your asp page

<asp:TextBox id="txtTextBox" runat="server"/>
<asp:CustomValidator id="cvLengthValidator" runat="server" OnServerValidate="cvLengthValidator_OnServerValidate" ErrorMessage="Minimum Length is 10" ControlToValidate="txtTextBox"/>

in your code behind

protected void cvLengthValidator_OnServerValidate(object sender, ServerValidateEventArgs e)
{
       e.IsValid = e.Value.ToString().Length > 10;
}
0

You can use a RegularExpression validation for this purpose.

<asp:TextBox ID="TextBox1" runat="server"  />
<asp:RegularExpressionValidator ID="regExTextBox1" runat="server" 
   ControlToValidate="TextBox1"
   ErrorMessage="Minimum password length is 10"
   ValidationExpression=".{10}.*" />

Hi, Thanks for solution.....

0

Hi kailasgorane,

Please mark this thread as solved if your question is answered.

Regards
Ramesh. S

0

In Textbox i want to enter the India phone no The textbox take 10 digits only not more than one number

0

To resolve this issues.go for custom validator along with regexpression for phone number validating.To get the regular expression for phone number

Expression : ^((+)?(\d{2}[-])?(\d{10}){1})?(\d{11}){0,1}?$
Description : India phone number, accept with optional +91 national code and 0 for land and mobile number prefix . Allows optional - after national code

for more info Click Here

hope this will help you.

0

Thanks Ramesh.. It worked for me.

I've one more question can I check for value of the textbox like if value should be atleast 500 or more??

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.