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;
}