Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: allow all currency symbols

Reply
Thread Tools

Re: allow all currency symbols

 
 
Peter Blum
Guest
Posts: n/a
 
      10-20-2004
Hi, please see my response to the same question that you posted here on
www.asp.net forums:

http://www.asp.net/Forums/ShowPost.a...&PostID=724575

--- Peter Blum
www.PeterBlum.com
Email: http://www.velocityreviews.com/forums/(E-Mail Removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"magister" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) m...
> Hello,
>
> Is there a way I can validate the input on a textbox for currency
> including all currency symbols..
>
> At the moment I have it only for the current culture info, but most
> banks use several different currencies...
>
> Thanks for any clues....
>
> Here's what I have so far...
>
>
> try
> {
> Result = Double.Parse(args.Value, NumberStyles.Any);
> done = true;
> }
> catch
> {
> done = false;
> }
>
> if (done)
> {
> args.IsValid = true;
> }
> else
> {
> args.IsValid = false;
> }



 
Reply With Quote
 
 
 
 
magister
Guest
Posts: n/a
 
      11-03-2004
Thanks for the reply. I felt I had to share how I did this to the
world who doesn't require client-size validation(quick search on the
web will bring back support for currency validation with
symbols)...This supports all currency formats installed on the
system....

private void Currency_ServerValidate(object source,
System.Web.UI.WebControls.ServerValidateEventArgs args)
{
bool done;
//Get the most frequent currencies
string reg = @"(\)|(\$)|(\)";
//parse win32 installed cultures for other currencies, check
CultureTypes enum for more
foreach(CultureInfo ci in
CultureInfo.GetCultures(CultureTypes.InstalledWin3 2Cultures))
{
if ( reg.IndexOf(ci.NumberFormat.CurrencySymbol) == -1 )
reg += "|("+ci.NumberFormat.CurrencySymbol+")";
}

Regex re = new Regex(@"("+reg+")");
//only allow one currency mark to be replaced
string wosymb = re.Replace(args.Value,"",1);

//try to parse what's remaining into a decimal type, if it fails it
ain't valid.
try
{
decimal Result = decimal.Parse(wosymb,
System.Globalization.NumberStyles.Currency);
done = true;
}
catch(Exception ex)
{
ex = ex;
done = false;
}

if (done)
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}
}

"Peter Blum" <(E-Mail Removed)> wrote in message news:<#(E-Mail Removed)>...
> Hi, please see my response to the same question that you posted here on
> www.asp.net forums:
>
> http://www.asp.net/Forums/ShowPost.a...&PostID=724575
>
> --- Peter Blum
> www.PeterBlum.com
> Email: (E-Mail Removed)
> Creator of "Professional Validation And More" at
> http://www.peterblum.com/vam/home.aspx
>
> "magister" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) m...
> > Hello,
> >
> > Is there a way I can validate the input on a textbox for currency
> > including all currency symbols..
> >
> > At the moment I have it only for the current culture info, but most
> > banks use several different currencies...
> >
> > Thanks for any clues....
> >
> > Here's what I have so far...
> >
> >
> > try
> > {
> > Result = Double.Parse(args.Value, NumberStyles.Any);
> > done = true;
> > }
> > catch
> > {
> > done = false;
> > }
> >
> > if (done)
> > {
> > args.IsValid = true;
> > }
> > else
> > {
> > args.IsValid = false;
> > }

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Currency Symbols David C ASP .Net 8 10-12-2009 01:38 PM
Displaying currency symbols in select James Sturrock Ruby 6 08-20-2007 12:56 PM
newbie: allow deny vs deny allow Jeff ASP .Net 2 09-19-2006 02:12 AM
Currency Symbols in tooltip JPike ASP .Net Web Controls 1 11-15-2004 04:04 PM
Storing Currency Symbols in Database J P Singh ASP General 4 01-27-2004 05:20 PM



Advertisments