vue-verification-code-input icon indicating copy to clipboard operation
vue-verification-code-input copied to clipboard

clear / reset

Open nonomaxxis opened this issue 3 years ago • 5 comments

hi, how can clear or reset Code Input?

nonomaxxis avatar Apr 23 '21 12:04 nonomaxxis

I think, change v-model field to empty

zerogravity2020 avatar Apr 26 '21 11:04 zerogravity2020

this.$refs.[refComponent].values = [empty array of values] solve your problem

zerogravity2020 avatar Apr 30 '21 09:04 zerogravity2020

@suweya hi, first of all much thanks for this component! And can tou please add an example with passing valuse for the component? I'm trying do it like this :values=[1,2,4,0] but value is not setted/reseted. zerogravity2020's advice just destroy all the compoent

kukzik avatar Jun 08 '21 19:06 kukzik

to empty the input fields you can use refs this way <codeInput ref='code' v-on:complete='onCompleted'>

in a method like for example, I want to clear the fields when the user is completed all the fields

onCompleted(v) {
     ..........
      this.$refs.code.values = ['','','','','']

    }

edouardyonga avatar Jun 10 '21 13:06 edouardyonga

If you want to reset the input and move the cursor to the first cell you can do it like that:

        this.$refs.code.values = ['','','',''];
        const name = this.$refs.code.iRefs[0];
        const element = this.$refs.code.$refs[name][0];
        element.focus();
        element.select();

DanielKusyDev avatar May 11 '22 18:05 DanielKusyDev