The mendix approach is to define validation rules for entities, that apply to the attribute that the user is entering in the text field. You can find these validation rules if you go to the properties for an entity in the domain model
Note that the validation will only take place after the user clicks a button to submit the form, meaning he can still enter anything in the text field.
PS: Here is guide by mendix on data validation - https://docs.mendix.com/howto/data-models/setting-up-data-validation
You can use the input mask for this: https://docs.mendix.com/refguide/text-box#input-mask-only-in-web-forms.
The input mask limits what the user can enter in the text box. A ‘9’ means any digit, ‘Z’ means any letter, ‘U’ an upper-case letter, ‘L’ a lower-case letter and ‘*’ a letter or a digit. Other characters will be taken literally. For example, the input mask 99-LLL-9999 matches 24-apr-2008.
Hopes this help.