RegularExpressionValidator that Accepts Only Floating/Double Numbers

Last post 11-22-2007 4:21 AM by ram_krish86. 4 replies.

Sort Posts:

  • RegularExpressionValidator that Accepts Only Floating/Double Numbers

    02-04-2007, 2:42 AM

    Hi,

    What is the regular expresstion that I should use in order to accept only floating/double numbers. That's it; only digits are accepted with any amount and only one or none "." (dot) character is accepted, just like the below examples:

    • 32.546
    • .342
    • 662
    • 7.3 

     

    Thanks in advance.

  • Re: RegularExpressionValidator that Accepts Only Floating/Double Numbers

    02-04-2007, 3:59 AM
    Answer
    • Loading...
    • CSharpSean
    • Joined on 10-21-2006, 5:43 AM
    • Orlando, FL
    • Posts 873

    Use this regular expression:

    ^\d*\.?\d*$

    Regular Expression Reference/Library
     

  • Re: RegularExpressionValidator that Accepts Only Floating/Double Numbers

    02-04-2007, 4:29 AM

    Thanks, that worked fine.

     But the only thing that it allows emty string. Could we make it don't accept empty string also without using the RequiredFieldValidator control?

  • Re: RegularExpressionValidator that Accepts Only Floating/Double Numbers

    02-23-2007, 10:18 AM
    • Loading...
    • Sohnee
    • Joined on 02-02-2007, 10:18 PM
    • UK
    • Posts 490

    You have to use the RequiredFieldValidator in addition to the RegularExpressionValidator - as it only fires the RegularExpressionValidator if there is something to validate (you might have a phone number field that is optional, but if they enter something, you want it to be a valid phone number).

  • Re: RegularExpressionValidator that Accepts Only Floating/Double Numbers

    11-22-2007, 4:21 AM
    • Loading...
    • ram_krish86
    • Joined on 11-06-2007, 12:54 AM
    • Hyderabad
    • Posts 56

    the link is v. coolll!!!Yes

    Ramakrishna.N
Page 1 of 1 (5 items)