0

 <input class="otp-number-login" 
                         input-classes="otp-number-login" type="password" placeholder="-" />
                        <input class="otp-number-login" 
                        input-classes="otp-number-login"  type="password" placeholder="-" />
                        <input class="otp-number-login"
                         input-classes="otp-number-login"  type="password" placeholder="-" />
                        <input class="otp-number-login"
                         input-classes="otp-number-login" type="password" placeholder="-" />

<v-otp-input
                              ref="otpInput"
                              input-classes="otp-number-login"
                              separator=""
                              :num-inputs="4"
                              :should-auto-focus="true"
                              :is-input-num="true"
                              input-type="password"
                              @on-change="handleOnChange"
                              @on-complete="handleOnComplete"
                            />

Reference from https://www.npmjs.com/package/@bachdgvn/vue-otp-input

I am having otp input field, So in the middle of each input field, I want place "-".

("-" is prefilled in otp field,before entering otp )

2 Answers 2

1

A workaround is to select the component's inputs, and set the placeholder:

export default {
  async mounted() {
    await this.$nextTick()
    this.setInputPlaceholder()
  },
  updated() {
    // also apply placeholder in `updated()` in case component gets re-rendered
    this.setInputPlaceholder()
  },
  methods: {
    setInputPlaceholder() {
      this.$refs.otpInput.$el
        .querySelectorAll('input')
        .forEach(input => input.placeholder = '-')
    },
  },
}

demo

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks for answering my question. After replacing the above code, i am getting error as (error Assignment to property of function parameter 'input' no-param-reassign)
In order to clear the error i have placed in the method "/*eslint no-param-reassign: "error"*/" Now the issue is, At the beginning, placeholder is not showing(Only showing placeholder if i enter any digit, then only its reflecting)
That doesn't occur in the demo. Can you link to a reproduction?
Yes in the demo, it's working fine, but in my local when adding above code, In console i am getting as(((((( "TypeError: Cannot read property '$el' of undefined"
I am thinking because of this, initially placeholder is not reflecting. Can you please check if anything to be added
|
0

This option has not been supported by the creator yet.

There is an issue on the git repo open since March 2:
https://github.com/bachdgvn/vue-otp-input/issues/41

2 Comments

Any other alternative ways, For placing the placeholder.(With css?)
I recommend that you create your own input or fork this input to do it on your own.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.