Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The texbox should allow the user to accept the format like 10.5 or 9.5 , in both case the user should be able to enter only one digit after the decimal point.
Posted

1 solution

Try:
^\d{1,2}\.\d$
 
Share this answer
 
Comments
Member 10593922 13-Feb-14 7:30am    
Can you write the complete syntax to add the above line?.
OriginalGriff 13-Feb-14 7:44am    
That is the entire syntax of the regular expression.
Are you saying you don't know how to use a regex?
Member 10593922 13-Feb-14 23:31pm    
Yes, since am new to C#, i dont know how to use this regular expression in a method
OriginalGriff 14-Feb-14 4:22am    
OK - do you know the Regex class?
Regex checker = new Regex(@"^\d{1,2}\.\d$");
if (checker.IsMatch("10.2"))
{
// It's Ok.
}
else
{
// It's bad.
}
Member 10593922 14-Feb-14 5:55am    
thank you.

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