Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm using .net 4.0 with C#. In text box when we enter numbers that text box accept only below 24 numbers!( If we enter 25, 26,27... these numbers will no display in that text box) , at the same time that text box accepts two decimals only (Ex: 12:00,1:00.....).

It is possible to do this? Can any one pls help me !!
Posted

Use the RangeValidator control on the textbox.
In this example[^], only values between 30 and 40 are accepted.
 
Share this answer
 
Comments
Uday P.Singh 16-Dec-11 3:18am    
5ed :)
Abhinav S 16-Dec-11 3:22am    
Thank you Uday.
RaviRanjanKr 16-Dec-11 3:37am    
5+
Abhinav S 16-Dec-11 3:42am    
Thanks Ravi.
thatraja 16-Dec-11 3:47am    
5!
Alternatively you can use regular expressions[^]. Use RegularExpressionValidator Control[^]
 
Share this answer
 
Comments
RaviRanjanKr 16-Dec-11 3:37am    
5+
Abhinav S 16-Dec-11 3:42am    
5!
To set textbox property as maxlenghth=24
 
Share this answer
 
Comments
[no name] 16-Dec-11 4:55am    
Where can i declare?
<asp:TextBox ID="TextBox1" runat="server" maxlenghth="24">

is it correct?
[no name] 16-Dec-11 6:02am    
it will set maxlength to text box.
if we enter 25 it will aceepted na?
that mean we can enter 24 character maximum in the textbox
[no name] 16-Dec-11 6:03am    
for the given result we have to used regular expression validator.
it is best.
thank u.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900