Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with mask #48

Open
samik3k opened this issue Jun 15, 2018 · 4 comments
Open

Problem with mask #48

samik3k opened this issue Jun 15, 2018 · 4 comments

Comments

@samik3k
Copy link

samik3k commented Jun 15, 2018

So i have

{{ phone }}
		<label for="phone">Phone</label>
		<masked-input
			id="phone"
			class="form-control string"
			v-model="phone"
			mask="\+\7 111 111-11-11"
			placeholder=""
			type="tel" />
	</div>

And i have phone: '72731241241',
Every time i open this modal i will get +7 727 312-41-24
Next try +7 772 731-24-12
And next +7 777 273-12-41
And next +7 777 727-31-24...

@elblasto
Copy link

elblasto commented Aug 3, 2018

Same problem

@a2exfr
Copy link

a2exfr commented Dec 30, 2018

It' look like mask work wrong, when send model data back to input.
Example I have mask ="+\9\6\2 111-11-11" and enter number + 962 333-33-33. After save correct number, and then try edit, and put data back to input - result is + 962 962-33-33. It's not cut static numbers at beginning.
Solution can be to save raw value@input="rawVal = arguments[1]" and use it.
Or in my case, I just cut static start of mask

<masked-input  v-model="userPhone" mask="\+\9\6\2 / 11 / 111/ 1111" placeholder="Phone"/>
data() {
		return {
			phone: '',
},
computed: {
		userPhone: {
			set(val) {
				this.phone = val;
			},
			get() {
				return  this.phone.substring(4);
			},
		},
}

@langald
Copy link

langald commented Mar 5, 2019

Same problem

@NetworKKnighT
Copy link

It can be fixed by replacing in MaskedInput.js this line
[...this.$refs.input.value].reduce((memo, item) => this.maskCore.input(item), null);
with
this.maskCore.paste(this.$refs.input.value);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants