Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need a regular expression for validation control

Posted on 2014-03-19
2
Medium Priority
?
321 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 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 39939675
^(?:\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
ID: 39939683
Thank you very much!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
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…
Suggested Courses

886 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