Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Prevent field clean when changing mask #576

Open
cesartagplus opened this issue Aug 24, 2023 · 0 comments
Open

Prevent field clean when changing mask #576

cesartagplus opened this issue Aug 24, 2023 · 0 comments

Comments

@cesartagplus
Copy link

Hi!

I have a dynamic mask, and when the mask changes (based on another inputs) it cleans the field. I want to prevent this, and clean the field only if the test fails. Is there a way ?

the code looks like this:

          <el-input
            v-model="test"
            v-mask="customMask"
          />
watch: {
 inputC: {
      immediate: true,
      handler () {
        this.customMask = this.changeMask(inputA, inputB)
      }
    }
}
methods: {
changeMask = (inputA, inputB) => {
 
  let actualMask = []

  if (inputA) {
    actualMask = [/1/, '.', /\d/, /\d/, /\d/]
  }

  if (inputB) {
    actualMask = [/2/, '.', /\d/, /\d/, /\d/]
  }
  
  return actualMask
}
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant