Comments (10)
hmm... I will check. You are using v1.x (for vue-2.x), right?
from v-mask.
i`m using 2.x.. i want change by conditional..
<input type="radio" id="cpf" value="cpf" name="type" v-on:change="onChange">
<input type="radio" id="cnpj" value="cnpj" name="type" v-on:change="onChange">
..
<input v-mask="maskDoc" type="text" name="doc" >
...
data: function () {
return {
maskDoc = '###.###.###/###';
}
},
...
onChange : function(e){
var radio = e.srcElement;
var value = radio.value;
if(value == 'cpf'){
this.maskDoc = '###.###.###/###';
}else{
this.maskDoc = '###.###.#####/###-##';
}
}
....
from v-mask.
I am having the same problem on my job.
from v-mask.
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = function (Vue) {
Vue.directive('mask', {
bind: function bind(el, _ref2) {
var value = _ref2.value;
var handlerFunc = handler.bind({ format: value });
el.addEventListener('input', handlerFunc, false);
return handlerFunc({ target: el });
},
componentUpdated(el, {value,oldValue}){
if(value !== oldValue){
var elClone = el.cloneNode(true);
el.parentNode.replaceChild(elClone, el);
console.log("Old" + oldValue);
console.log("value" + value);
let handlerFunc = handler.bind({format: value});
elClone.addEventListener('input', handlerFunc, false);
return handlerFunc({target: elClone});
}
},
unbind: function unbind(el) {
el.removeEventListener('input', handler, false);
}
});
};
var _format = require('./format.js');
var _format2 = _interopRequireDefault(_format);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function handler(_ref) {
var target = _ref.target;
var previousValue = target.dataset.previousValue;
if (typeof previousValue === 'string' && previousValue.length < target.value.length) {
target.value = (0, _format2.default)(target.value, this.format);
}
target.dataset.previousValue = target.value;
}
;
from v-mask.
This is working for me
from v-mask.
@icaio Why you are changing compiled version?
BTW, this feature will be implemeted in the next release. It's already fixed
from v-mask.
Oh thanks :D
from v-mask.
@icaio , @lucassmacedo
Try latest master
. I have already fixed it
from v-mask.
@probil the mask is working, but when you change the mask and type, the field lost focus and lost the previous value.
from v-mask.
@icaio Ok, the PureMask.js (the formatting function) is not "smart" enough to be able to parse old data with new mask. So, I'm going to use another lib or write my own. There is a lot of issues with PureMask.js
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.