React-number-format: Show mask after focusing the input

Created on 11 Nov 2019  路  5Comments  路  Source: s-yadav/react-number-format

Hello, can you help me please?

Is there a way to show mask (and put the caret to right position) when we just focus on input? And then if we focus out the input, hide the mask? Or the is an option just to always show mask?

I need to format phone number with '+7 (###) ###-####' mask, but when i focus on the input it shows no mask and only after user starts typing the mask appears and put user's value in the (###) field.

My goal is to achieve the next: always show the user that "+7" is already set, and he will start his input inside (###), when he is focusing the input.

Most helpful comment

@s-yadav Thank you. But then the mask is always shown. Is there any way to show it only on focus?

All 5 comments

Humm, the requirement makes sense. I will see if we can incorporate this in the library.

This feature is really needed. That's the only reason I have to use one more library for phone masks.

@iloveip @everlasting-neverness
I forgot. This prop is already present. Set allowEmptyFormatting to true.
https://github.com/s-yadav/react-number-format#props

I will add it in examples and codepen as well.

@s-yadav Thank you. But then the mask is always shown. Is there any way to show it only on focus?

Hi @s-yadav and @iloveip,

Same request here, being able to display mask only when input focused or have value would be really user friendly.

Yours faithfully,
LCDP

Was this page helpful?
0 / 5 - 0 ratings

Related issues

osvaldokalvaitir picture osvaldokalvaitir  路  3Comments

cescoferraro picture cescoferraro  路  6Comments

luis-carlos-campos picture luis-carlos-campos  路  3Comments

tenkij picture tenkij  路  6Comments

lucasglobalsys picture lucasglobalsys  路  5Comments