Improve company productivity with a Business Account.Sign Up


check money in regex

Posted on 2013-01-30
Medium Priority
Last Modified: 2013-02-14
I want to check if it is a good $ amount and txtpriceamount can not be blank.  It could also be a negative number.  txtpriceamount is required.

10.00 yes
1.00 yes
0.00 yes
0.02 yes
0.00 yes

-10.00 yes
-1.00 yes
-0.00 yes
-0.02 yes
-0.00 yes

1 no
text is no

 <asp:TextBox ID="txtpriceamount" runat="server"></asp:TextBox>
              &nbsp;<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
                    ControlToValidate="txtpriceamount" ErrorMessage="Incorrect Amount" ValidationExpression="^[1-9]+\d*\.\d{2}$"></asp:RegularExpressionValidator>
Question by:VBdotnet2005
  • 2
LVL 41

Accepted Solution

guru_sami earned 1000 total points
ID: 38837467
Are those the only numbers you want or you want to have any valid money value?

Here's one:

Open in new window

All below will be valid. But it can be adjust to your requirement.


This  will not allow commas:

Open in new window

FYI: Try tool like Expresso for creating/testing regexs..
LVL 29

Assisted Solution

by:Kumaraswamy R
Kumaraswamy R earned 1000 total points
ID: 38838398
This worked too.
LVL 41

Expert Comment

ID: 38840617
For the "txtpriceamount can not be blank.":

You simply add a RequireFieldValidator for the textbox in addition to your ReqFieldValidator.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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…
An ASP.NET Web Form User Control is not newly introduced in ASP.NET. In fact, it was an old technology yet still playing a role to generate web content, especially when we want to use it to have a better and easy way to control part of the web conte…
Watch the video to know how one can repair corrupt Exchange OST file effortlessly and convert OST emails to MS Outlook PST file format by using Kernel for OST to PST converter tool. It can convert OST to MSG, MBOX, EML to access them. It can migrate…
To export Lotus Notes to Outlook PST or Exchange and Domino Server files to Exchange Server or PST files with ease, go for Kernel for Lotus Notes to Outlook conversion tool. Through the video, you can watch the conversion process. A common user with…

601 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