question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using v-mask directive on `b-form-input` not transferring to `input` element

See original GitHub issue

Hello team,

I’m working with the v-mask (v1.3.0) plugin and attempting to use the v-mask directive on the b-form-input component like so:

<b-form @submit.stop.prevent="onSubmit">
    ... 
    <b-input-group left="Mobile*">
      <b-form-input
        type="text"
        v-model="mobile"
        v-mask="'###-###-####'"
        placeholder="___-___-____" />
    </b-input-group>
    ...
  </b-form>

The v-mask directive is turned into data-mask on the actual input element when everything gets compiled down and mounted to the DOM. I have been able to test this directive on a simple input element and it works and other custom input elements outside of bootstrap-vue work too (and they do not transform to data-mask property). I’m wondering if this could be a bug or if it’s expected behavior. Any ideas on what could be going wrong would be greatly appreciated.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
DavidViniciuscommented, May 8, 2020

I had the same problem using the Awesome Mask, but in my case, I imported wrongly the directives in the main.js file. When I used Vue.directive('mask', AwesomeMask);, then every worked.

0reactions
AlexcastroDevcommented, Oct 22, 2020

Did anyone find a solution to this?

Yes, its easy!

in your b-form-input, set @focus=“checkMask(id, mask)”

create this method and Voialá!

checkMask( mask, id ) {
                 let el = document.getElementById(id);
                el.setAttribute("v-mask", mask);
            },
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to transform input values using v-mask when building ...
5. Now, go back to our new <input> element and apply v-model . We are also going to now add the v-mask directive,...
Read more >
Form Input | Components - BootstrapVue
Create various type inputs such as: text, password, number, url, email, search, range, date and more.
Read more >
Vue - directive bind doesn't work on element refresh
User must go to question without mask, then go back and it will work again. After debugging, I know, that element is refreshed,...
Read more >
Masking form input values - Adobe Support
Masking form input values ... The cfinput tag mask attribute controls the format of data that can be entered into a text or...
Read more >
The Mask for Vue.js - vuejs-tips
The value returned from directive is always masked! When possible, prefer to use input type="tel" to avoid glitch on android devices. What about...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found