Skip to content

[React] Is there any way to avoid overwrite when a certain character is entered? #1014

Answered by uNmAnNeR
DeltaSPb asked this question in Q&A
Discussion options

You must be logged in to vote

hi @DeltaSPb,
well, it's a hard one.

I am going to have the ability to control overwrite from child masks in v8.
For now maybe custom dispatch could help.
Or toggle overwrite in prepareChar depending on the char. It's a dirty hack but it might help.

<IMaskInput
  mask={mask}
  overwrite={true}
  placeholder={placeholder}
  placeholderChar={placeholderChar}
  type={"text"}
  inputRef={inputRef}
  value={value}
  autoComplete={"off"}
  onAccept={onChange}
  prepareChar={(char, masked) => {
    masked.overwrite = Boolean(masked.value) || char !== "-";
    return char;
  }}
  blocks={{
    DD: [{ mask: "0[00]" }, { mask: "-0[00]" }, { mask: "+0[00]" }],
    MM: { mask: "0[0]" },
    SS: { mask: 

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by DeltaSPb
Comment options

You must be logged in to vote
2 replies
@uNmAnNeR
Comment options

@DeltaSPb
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants