Hi all,
I'm trying to put something together that validates a textbox against a regular expression that defines currency, so on each key press, if the text does not match a valid currency amount it handles that key press.
Here's the code i'm using:
When I run this code it misbehaves, allowing some numerical input but not all that you would relate to a currency format. For example if I enter "01." it will then not let me enter any more numbers, even though it should allow "01.00". Any ideas what I'm doing wrong?Code:private void InputMoney(KeyPressEventArgs e, string s) { if (!Regex.IsMatch(s, @"^\$?([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(.[0-9][0-9])?$")) { e.Handled = true; }
Thanks.



LinkBack URL
About LinkBacks


