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..c27e87e5d87 100644 --- a/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Regex.Data.cs +++ b/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Regex.Data.cs @@ -53,6 +53,11 @@ public enum ValidationType /// Decimal, + /// + /// Currency validation + /// + Currency, + /// /// Text only validation /// 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..e15fd702c48 100644 --- a/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Regex.Internals.cs +++ b/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Regex.Internals.cs @@ -70,6 +70,12 @@ private static void ValidateTextBox(TextBox textBox, bool force = true) case ValidationType.Decimal: regexMatch = textBox.Text.IsDecimal(); break; + case ValidationType.Currency: + // @"(^\d*\.\d{2}$)" regex pattern to detect currency sign with currency value + // Mathes: $100.00, $100, $10.25 + // Non-Matches: 100., $10.233, $10. + regexMatch = Regex.IsMatch(textBox.Text, @"^\$( )*\d*(.\d{1,2})?$"); + break; case ValidationType.Email: regexMatch = textBox.Text.IsEmail(); break;