microsoft / fluentui-blazor

Microsoft Fluent UI Blazor components library. For use with ASP.NET Core Blazor applications
https://www.fluentui-blazor.net
MIT License
3.81k stars 370 forks source link

feat: add masking to Text Field #1190

Closed GamingMaker closed 10 months ago

GamingMaker commented 10 months ago

πŸ™‹ Feature Request

I thought it would be a great feature to add the option of masking into the Text Field. You could provide a pattern and the textfields behaves according to it. Let me give an example: Pattern = "xxxx.xxxx" and the Text Field gets pre-filled like this: "____x____". Every time the end-user inputs a character, one underscore disappears and the character is in the position. Also: the end-user can't provide more characters than the pattern length and every time he removes one character, the underscore comes back to the position. Also if the pattern is like "dd.mm", the field should only accept valid inputs, unlike for example "51.56", since this is not a correct format.

This would be a nice addition to the text fields, especially for using the text fields in forms.

πŸ’ Possible Solution

You could add a "Pattern" or "Mask" parameter into the Text Field where a user can provide a pattern for the masking. Example: Pattern="dd.mm" and the field gets pre-filled with underscores: "__.__". The maxlength and minlength Parameters should be set to the lenght of the pattern.

πŸ”¦ Context

What are you trying to accomplish? -> having a masked text input inside a form.

How has not having this feature affected you? -> i tried implementing it myself but i'm not that experienced and it works in general but could be way better.

πŸ’» Examples

image

image

image

vnbaaij commented 10 months ago

This is currently not possible as it is not supported by the underlying web component.