Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I want code for regularexpression validator which allows 4 digit before decimal and 2 digit after decimal.....I used below code but it is not working...If I enter 5 digit before decimal it is saving in database....Please help me ..........

XML
<asp:RegularExpressionValidator runat="server" ID="regLSLExpVal"
                ControlToValidate="txtLSL" Display="None" ErrorMessage="Only 4 digits are allowed before decimal."
                ValidationExpression="^\d{1,4}(\.\d{1,2})?$" >
            </asp:RegularExpressionValidator>
Posted
Updated 25-Jun-13 22:12pm
v2
Comments
OriginalGriff 26-Jun-13 4:19am    
Don't bump your question. It's rude and not likely to improve your chances of a helpful answer.
Adding "Please help me......." does not improve your question.

1 solution

This should do it:
^(\d{4}(.\d{2}))$

To validate it visit :
JavaScript RegExp Example: Regular Expression Tester[^]

--Amit
 
Share this answer
 
v3
Comments
16Sonali 26-Jun-13 4:50am    
Thanks a lot......
_Amy 26-Jun-13 4:52am    
Welcome. Will you accept the answer formally(Green Button)?
16Sonali 26-Jun-13 5:00am    
yeah!!!sure
16Sonali 26-Jun-13 5:08am    
Hi...I tried ^(\d{4}(.\d{2}))$ this way also...but still accepting 5 digit before decimal
_Amy 26-Jun-13 5:16am    
On form submit, is it not validating your input? See the given link with this solution.

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