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

Ability to define mask placeholders #128

Closed
3 tasks
probil opened this issue Mar 5, 2018 · 2 comments
Closed
3 tasks

Ability to define mask placeholders #128

probil opened this issue Mar 5, 2018 · 2 comments

Comments

@probil
Copy link
Owner

probil commented Mar 5, 2018

It would be nice to have ability to add/remove/replace custom mask placeholders.
Predefined placeholders are not enough in some cases.
Currently the idea is to pass placeholder definitions to the plugin options. This will apply to all masks.

Vue.use(VueMask, { 
  placeholders: {
    // define new placeholder
    'S':  /[a-z]/.test,

    // remove existing placeholder
    '#': null,

    // replace existing placeholder
    'N':  /[a-z]/.test,
    },
  },
});

Plus we should be able to do the same for one mask only.

<template>
  <input v-mask="['(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/]" />
</template>

TODO:

  • Accepts array of regular expression directly
  • Add/remove/replace global mask placeholders
  • Update README

Test cases:

@github-actions
Copy link

🎉 This issue has been resolved in version 2.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Code8525
Copy link

Code8525 commented Dec 6, 2021

Vue.use(VueMask, { 
  placeholders: {
    // define new placeholder
    'S':  {
                pattern: /[0-9a-zA-Z]/, 
                transform: function (e) {
                    return e.toLocaleUpperCase()
                }
          }
    },
  },
});

Hello!
You need something like this to have maximum flexibility.
No way to raise to uppercase

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants