Topic: How to create a variable-length mask
DashMarketingGroup pro premium priority asked 5 months ago
I am trying to use the input-mask for afield where the user needs to be able to enter as few as 3 digits or as many as 5 digits. So, for example, they might enter 123 or 12345. The problem is, the following code requires the user to enter 5 digits. If they enter fewer digits then it fails"
<input type="text" id="tbTermsLimit" name="tbTermsLimit" class="form-control form-control-sm fs-6 w-50" data-mdb-input-mask-init data-mdb-input-mask="999999" />
I haven't figured out how to change this so that I can use the input-mask and let the user enter between 3 and five digits. I tried this, but it didn't work:
<input type="text" id="tbTermsLimit" name="tbTermsLimit" class="form-control form-control-sm fs-6 w-50" data-mdb-input-mask-init data-mdb-input-mask="9[3-5]" />
Any help you can offer would be appreciated. Thank you!
Grzegorz Bujański staff answered 5 months ago
Unfortunately, we do not support this solution. But you can use data-mdb-clear-incomplete="false"
and add field validation to check if 3 or more characters are provided.
DashMarketingGroup pro premium priority commented 5 months ago
Do you plan on adding the ability to use RegEx expressions for the input-mask? It would be a GREAT addition.
Grzegorz Bujański staff commented 5 months ago
At the moment no. But I'll add it to the list of ideas and maybe one day we'll add that option.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 7.3.2
- Device: laptop
- Browser: chrome
- OS: win11
- Provided sample code: No
- Provided link: No