Need validaton expression for the following

Posted on 2011-05-08
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
    LVL 15

    Expert Comment

    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

    for common regular expression validations:

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

    Expert Comment

    by:käµfm³d 👽
    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 . 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 74

    Accepted Solution

    Correction to the above patterns (I forgot to escape the dot):


    Open in new window


    Open in new window


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    728 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

    17 Experts available now in Live!

    Get 1:1 Help Now