Click here to Skip to main content
16,015,481 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I found a source where it is 6 digits before and two after but i do not know how to change

What I have tried:

<asp:TextBox ID="txtrate" runat="server" onkeypress="if(event.keyCode<48 || event.keyCode>57)event.returnValue=false;" MaxLength="9">

<asp:RegularExpressionValidator runat="server" ID="RegularExpressionValidator1"
ValidationExpression="^((\d{5})*|([1-9]\d{0,5}))(\.\d{0,2})?$"
ControlToValidate="txtrate" Text="Input must be 123456.78 format."
Display="Dynamic" />
Posted
Updated 6-Aug-16 6:06am
v3

Development isn't a process where you find something on the internet and paste it into your app: you are supposed to think about it and work out how it works (or better write it yourself).
In this case, you don't need anything that complex:
^\d\.\d\d$
Will do it.
 
Share this answer
 
Comments
Member 12652110 6-Aug-16 11:54am    
i tried
<asp:TextBox ID="txtrate" runat="server" onkeypress="if(event.keyCode<48 || event.keyCode>57)event.returnValue=false;" MaxLength="4">
<asp:RequiredFieldValidator id="RequiredFieldValidator5" runat="server" ErrorMessage="Rate is required!" ControlToValidate="txtrate" />
<asp:RegularExpressionValidator runat="server" ID="RegularExpressionValidator1"
ValidationExpression="^((\d{1})*|([1-9]\d{0,1}))(\.\d{0,2})?$"
ControlToValidate="txtrate" Text="Input must be 123456.78 format."
Display="Dynamic" />
Member 12652110 6-Aug-16 11:55am    
but it wont show error message
Member 12652110 6-Aug-16 11:56am    
could you help me out as i am a student and my deadline is tmr
BillWoodruff 6-Aug-16 12:12pm    
And, who is responsible for your waiting until the last minute to study ?
Member 12652110 6-Aug-16 12:14pm    
its not exam it was a project
I now realised that the flow was off for my validation thanks again if you could help
Try to state a question with a sentence telling what you want.
Use Improve question to update your question.

I guess you want to validate an input with another format than the example you found.
The tool used to do this is called Regular Expressions (RegEx)
Try this expression: ^\d\.\d{2}$
Here are tools to help you find what a RegEx is doing:
Debuggex: Online visual regex tester. JavaScript, Python, and PCRE.[^]
.NET Regex Tester - Regex Storm[^]
Expresso Regular Expression Tool[^]
Here is some documentation worth reading:
perlre - perldoc.perl.org[^]
 
Share this answer
 
Comments
Member 12652110 6-Aug-16 12:10pm    
^((\d{1})*|([1-9]\d{0,1}))(\.\d{0,2})?
Tried this but doesnt work
Patrice T 6-Aug-16 12:13pm    
Did you try to read the 2 solutions you have been given ?
Member 12652110 6-Aug-16 12:20pm    
oops my bad

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