Click here to Skip to main content
15,904,023 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
My regular expression is like that
rev.ValidationExpression = "[0-9]+([/./]?[0-9]?[0-9]?[0-9]?[0-9]?)?";

So if i enter 2.333333 like that showing error, but if i enter 3.(followed by decimal) only not showing error. apart from everything is working fine. Thanks in advance. that is whaat i wanted but when i enter it in my code still showing error . i want to get the
solution for if i dont enter anything after . it should show error. eg.4.(error)
Posted
Updated 26-Apr-11 0:26am
v4

I think you may want to change te regex to :
[0-9]+([\.]?[0-9]?[0-9]?[0-9]?[0-9]?)?
 
Share this answer
 
Comments
taher ahmed choudhury 26-Apr-11 6:20am    
if i enter ur code in my code showing unrecognised escape sequence after \
taher ahmed choudhury 26-Apr-11 6:22am    
still showing error
Kim Togo 26-Apr-11 7:19am    
You have to:

rev.ValidationExpression = @"[0-9]+([\.]?[0-9]?[0-9]?[0-9]?[0-9]?)?"
Eduard Keilholz 26-Apr-11 8:25am    
If you use C#, you have to esccape the '\' character. Use [0-9]+([\\.]?[0-9]?[0-9]?[0-9]?[0-9]?)? instead, or @"[0-9]+([\.]?[0-9]?[0-9]?[0-9]?[0-9]?)?"

Have fun!
taher ahmed choudhury 27-Apr-11 0:21am    
still not validating if i enter digit followed by decimal eg.3. apart from the rest are working
fine. so i need ur help. thanks in advance.
Thanks for the question
and here is the answer for it [0-9]+([/./]+?[0-9]+?[0-9]?[0-9]?[0-9]?)+? or
\d+([\.]+?\d+?\d?\d?\d?)+? and to learn more about regex click on the following ling Click Here and in order to validate the regex Click Here
 
Share this answer
 

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