Solved

Need a regular expression for validation control

Posted on 2014-03-19
2
302 Views
Last Modified: 2014-03-19
I need a regular expression for a regular expression control that only allows numbers (any amount) to the left of decimal (if it needs a decimal) and then only 2 numbers to the right of the decimal.  They may or may not have a number and a decimal place.  But if they use a decimal place they can only input 2 numbers after it .

thanks in advance for the help.
0
Comment
Question by:mgmhicks
2 Comments
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
Comment Utility
^(?:\d+(?:\.\d{1,2})?)?$

Open in new window


If they must enter 2 numbers after the decimal--meaning they can't enter just one--then change {1,2} to {2}.
0
 

Author Closing Comment

by:mgmhicks
Comment Utility
Thank you very much!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Whatever be the reason, if you are working on web development side,  you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now