Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Need validaton expression for the following

Posted on 2011-05-08
Medium Priority
Last Modified: 2012-06-21
I have a textbox and have assigned a regular expression validator to it.
Basically I need to validate that the user enters only one decimal place. (i.e. only one digit after the decimal)

Some example valid scenarios are as follows:

1) 1.2
2) 0
3) .4
4) 1
5) '' (empty space or blank)

Also, if anyone could provide a good site which teaches how to build validation expressions, that would be helpful.
Question by:paradigm_IS
  • 2
  • 2
LVL 15

Expert Comment

ID: 35716542
I do´nt like regular expresions to validate numbers.
I use DataBinding, with format.
Using "N1", validates to a decimal place and also shows thousand separator.
You can also enter exponential values:  1.23e4 ->1230
it supports globalization (decimalpoint character).
It do correct validation for negative sign....
LVL 15

Expert Comment

ID: 35716615
for common regular expression validations:

Try: ^(-)?\d+(\.\d)
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35745785
x77's pattern won't handle the blank, the single digit, or the decimal with no leading digit, unfortunately. Try the following:


Open in new window

If you need the negative, x77's approach should work:


Open in new window

Also, if anyone could provide a good site which teaches how to build validation expressions, that would be helpful.

Open in new window

I prefer www.regular-expressions.info . Also, there is Expresso, a .NET regular expression tool, which you can use to build regular expressions. It has a feature that explains the regular expression.
LVL 75

Accepted Solution

käµfm³d   👽 earned 2000 total points
ID: 35745791
Correction to the above patterns (I forgot to escape the dot):


Open in new window


Open in new window


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

580 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