?
Solved

Validate curreny using ASP.NET validation control

Posted on 2006-11-15
6
Medium Priority
?
291 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
[X]
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
  • 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
Vim Reference Guide

Vim is a powerful text editor favored by many sysadmins and developers - here are some commands that you'll want to keep in your back pocket!

 
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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

718 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