Solved

Validate curreny using ASP.NET validation control

Posted on 2006-11-15
6
287 Views
Last Modified: 2008-02-01
I am trying to validate when a user enters a currency value.  I am using a range validator.  I have set the minimum value and the maximum values for the validator.  The problem that i am having is when the user includes a dollar sign ($) it will not validate becuase the $ is not valid.  How can i validate a currency entry even if the user includes the dollar sign?
0
Comment
Question by:Mike_Stevens
  • 4
  • 2
6 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 17948113
Try using CompareValidator with Type=Currency and Operator=DataTypeCheck
0
 
LVL 35

Expert Comment

by:YZlat
ID: 17948182
if you have to use currency symbol, then use either RegularExpression or CustomValidator
0
 

Author Comment

by:Mike_Stevens
ID: 17948211
That is what i am asking....i need to validate the entry if the user does or does not enter the dollar symbol.  The compare method you reccomended does not work.  
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
LVL 35

Expert Comment

by:YZlat
ID: 17948281
try this regular expression:

^(\$)?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$
0
 
LVL 35

Accepted Solution

by:
YZlat earned 500 total points
ID: 17948290
you'll need something like that:

<asp:RegularExpressionValidator id="RegularExpressionValidator1" runat="server" ErrorMessage="Invalid currency!" ControlToValidate="your control name here" ValidationExpression="^(\$)?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$"></asp:RegularExpressionValidator>
0
 

Author Comment

by:Mike_Stevens
ID: 17948326
That is exactly what i needed.  Thanks
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The viewer will learn how to dynamically set the form action using jQuery.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

807 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