Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
In my application I have text boxes in which user can enter number values i.e money... So I should restrict user should only insert numerics or decimals also

Example:
5000
266256.55
66666.54
8484.00

Please suggest me a best regex expression to accept only above formats in c#
Posted
Updated 19-Feb-14 19:22pm
v2
Comments
Shreyas Tg 20-Feb-14 1:19am    
^[1-9]\d*(\.\d+)?$
Maarten Kools 20-Feb-14 1:20am    
RegExr[^] has an online library of community expressions, I'm sure there is one available that applies for you.

1 solution

Go for Ajax tools
C#
<asp:TextBox ID="txtyearly" runat="server" Width="128px"></asp:TextBox><asp:FilteredTextBoxExtender
                       ID="FilteredTextBoxExtender6" TargetControlID="txtyearly" runat="server" FilterType="Numbers">
                   </asp:FilteredTextBoxExtender>
 
Share this answer
 
Comments
jing567 20-Feb-14 1:22am    
Can u suggest me how to apply in wpf application???
King Fisher 20-Feb-14 1:59am    
http://karlhulme.wordpress.com/2007/02/15/masking-input-to-a-wpf-textbox/

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