Comments (14)
from v-mask.
a workaround for using the createNumberMask
function until the PR is merged is as follows
// in your vue component, in the computed properties
mask() {
const currencyMask = createNumberMask({
prefix: '$',
allowDecimal: true,
includeThousandsSeparator: true,
allowNegative: false
});
currencyMask(this.value)
.map(v => String(v) === '\/\\d/' ? '#' : v)
.filter(v => v !== '[]')
.join('');
}
it takes the output of the currency mask and transforms it to the expected string input of v-mask
from v-mask.
May anyone help me, please? :)
from v-mask.
One way to achieve this that doesn't seem too crazy to me is to allow for a special character that can be mapped to a regex, and then map the regex to allow for digits, as well as commas and periods. Then you can use a function similar to the filter to process this amount on blur.
The markup might look something like <input type="text" v-mask="'RRRRRR'" v-mask-pattern="/[0-9.]/" v-model="myInputModel">
.
I implemented a similar feature using the jquery mask plugin years ago.
@probil Would it be difficult to add an option for custom regex patterns? I'd be happy to take a look if you are open to a PR...
from v-mask.
@alicesouto I couldn't wait for a response on this, so I created a component that masks the input, here's a gist: https://gist.github.com/nickforddesign/014639c694eaf2c88c3e1f323ba5b755
I had a few strong opinions about this that others might disagree with, like forcing the cursor to the end of the input on focus using the event.value = event.value
trick, I also always stick to 2 decimal places, so if the user inputs 12.5, it is converted to 12.50...
from v-mask.
Not yet supported by I have planed to make it work
from v-mask.
+1
from v-mask.
+1
from v-mask.
+11111111
from v-mask.
I'm busy right now to implement but it's not hard to implement.
Since we use text-mask-core
under the hood we can use addons to archive that.
There is createNumberMask
addon which can be used to format user input as currency
https://github.com/text-mask/text-mask/tree/master/addons/#createnumbermask
PR is welcome.
from v-mask.
ah I forgot I was going to write something for this..lemme give it a go.
from v-mask.
@kylemilloy check out pr #455, see if its what you were thinking
from v-mask.
Close to what I was thinking.
I was working on something to just accept an object where you pass it a mask type with options so you can do this all inline without any configuration or importing of additional libraries. Just do a quick <input v-mask="{type: 'number', options: {prefix: '$', }}" />
kind of idea.
Your way is definitely more flexible however.
from v-mask.
🎉 This issue has been resolved in version 2.2.1 🎉
The release is available on:
Your semantic-release bot 📦🚀
from v-mask.
Related Issues (20)
- Underscores ("_") break all masking HOT 2
- Dependency Dashboard
- Error using v-mask function in vuetify component HOT 2
- The mask doesn't work when you manually replace selected text HOT 1
- e.initEvent is deprecated
- Place holder optional (?) not working HOT 1
- How to deal with ip addresses HOT 3
- Is it possible to use pipes? HOT 1
- mask not working with ctrl a + ctrl v HOT 2
- The last 4 digits of the phone number are not hidden. The first 4 digits at the beginning of the number go to the end.
- Using v-mask in a text-area field HOT 1
- Editing v-text-field with phone number mask (NNN) NNN-NNNN causes cursor to move to end of field
- Masked input affected by typing in another field in case using function for v-mask HOT 1
- Bug when replacing through selection #1
- Bug when replacing through selection #2
- Vue.filter is not a function ? HOT 3
- input with mask cut value and add some number
- Prevent field clean when changing mask
- The automated release is failing 🚨
- Question / Feature : Help Needed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from v-mask.