[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

656 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