kyrylolv
kyrylolv

Reputation: 320

Mask MUI input to be able to add one or two digit number

I am implementing an input, where the user should type number in the following format: 12/34/56. I have found that react-input-mask allows to do so. But my question now is how to make the mask either require the user to fully enter the number (to remove such cases 1_/3_/_5) or add zeros where the number wasn't entered.

Also, another thing I think of is to allow either one or two digits, but I haven't seen documentation on this in react-input-mask

I am willing to choose another mask library, if you know it can be done so.

Upvotes: 1

Views: 749

Answers (1)

kyrylolv
kyrylolv

Reputation: 320

I figured it out. There is a property called maskChar, if you set it to null, e.g <InputMask maskChar={null} mask="99/99/99" /> won't allow user to proceed to second number, without filling both digits.

Upvotes: 1

Related Questions