A more reusable approach would be to make a custom
TextBox
with Mask
and some more properties (e.g. AllowInsert
, AllowSpacesInBetween
, etc.). Or attached behavior to enable certain rules dynamically (the cool thing would be to architecture rules interactions, so it can be easily extended further by just implementing a new rule without need to rewrite existing rules).