diff --git a/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Regex.Data.cs b/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Regex.Data.cs index 41cfaad55fa..32941880de9 100644 --- a/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Regex.Data.cs +++ b/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Regex.Data.cs @@ -61,7 +61,12 @@ public enum ValidationType /// /// Phone number validation /// - PhoneNumber + PhoneNumber, + + /// + /// Currency validation + /// + Currency } } } \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Regex.Internals.cs b/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Regex.Internals.cs index 1ffe92bd083..b95759837b8 100644 --- a/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Regex.Internals.cs +++ b/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Regex.Internals.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Diagnostics; +using System.Globalization; using System.Text.RegularExpressions; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; @@ -82,6 +83,9 @@ private static void ValidateTextBox(TextBox textBox, bool force = true) case ValidationType.Characters: regexMatch = textBox.Text.IsCharacterString(); break; + case ValidationType.Currency: + regexMatch = decimal.TryParse(textBox.Text, NumberStyles.Currency, CultureInfo.CurrentCulture, out _); + break; } if (!regexMatch && force)