473,326 Members | 2,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

allow all currency symbols

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;
}
Nov 18 '05 #1
2 2126
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: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"magister" <yu***@yahoo.co.uk> wrote in message
news:98*************************@posting.google.co 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;
}

Nov 18 '05 #2
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" <PL****@Blum.info> wrote in message news:<#N**************@TK2MSFTNGP11.phx.gbl>...
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: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"magister" <yu***@yahoo.co.uk> wrote in message
news:98*************************@posting.google.co 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;
}

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: J P Singh | last post by:
Hi Guys I am trying to store the currency symbol used for a trasaction in a database field but rather than store £ it stores £ (see the wierd character at the beginning of the symbol) instead....
2
by: Willing 2 Learn | last post by:
I'm still having trouble getting my program to do arithmetic in cents(keeping all #'s) then convert the answer in a format of dollars & cents. The main program should add, subtract, scalar...
2
by: Not Me | last post by:
Hi, I have a table with a currency field, which is displayed via a form. If I open a query which displays this field (using the forms!myform.field notation) that field displays as though it's...
4
by: Mitchell Vincent | last post by:
How is everyone formatting currency with VB.NET? Before I was calling the API function for it, which took the currency symbol from the Windows settings. I've found this to be limited when...
2
by: sck10 | last post by:
Hello, I have a SQL Server 2K table with a field set to currency. When I try to insert or update a FormView, I get the following error: Disallowed implicit conversion from data type nvarchar...
18
by: Boris Yeltsin | last post by:
OK, I have a database table, it has prices of products in it, like so: ProductPrice MONEY ProductIsoCurrencyCode CHAR(3) Now, both CultureInfo and RegionInfo have...
3
by: José Joye | last post by:
Hello, Is there an enum available within the .NET library which gives the valid ISO currency code? Thanks, -José
3
by: Eric | last post by:
I know this is a property of the RegionInfo class. I figure somewhere in the framework is the actual enumeration, which I would like to use. I want to use it to support a Money class I need,...
15
Zwoker
by: Zwoker | last post by:
Hello everyone, I have an MS Access 2003 application that is distributed as an MDE. All the users around the Asia/Pacific region that use it are running Windows XP. Many of them have...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.