Skip to content

Commit 83236c5

Browse files
committed
PlaceholderChar customize added
1 parent 3084d37 commit 83236c5

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ You can also get a raw user input text if you want. Instead of using v-model you
3232
<masked-input mask="+\\1 (111) 1111-11" placeholder="Phone" @input="rawVal = arguments[1]" />
3333
```
3434

35+
Placeholder character is customizable (`_` by default):
36+
```vue
37+
<masked-input v-model="phone" mask="+\\1 (111) 111-1111" placeholderChar="-" placeholder="Phone number" type="tel" />
38+
```
39+
3540
## Known issues/TODO
3641
* Cut in mobile Chrome
3742
* Cyrillic chars are not supported in mobile Chrome

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-masked-input",
33
"description": "Masked input component for Vue.js 2.X",
4-
"version": "0.2.3",
4+
"version": "0.2.4",
55
"author": "niksmr",
66
"license": "MIT",
77
"homepage": "https://github.com/niksmr/vue-masked-input",

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<li># – alphanumeric, forced to upper case when entered</li>
1616
</ul>
1717
<h4>Date: </h4>
18-
<masked-input v-model="date" mask="11 / 11 / 1111" placeholder="Date"/><span v-if="">{{ date }}</span>
18+
<masked-input v-model="date" mask="11 / 11 / 1111" placeholder="Date"/><span>{{ date }}</span>
1919
<p class="code">
2020
&lt;masked-input v-model="date" mask="11 / 11 / 1111" placeholder="Date" /&gt;
2121
</p>

src/MaskedInput.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ export default {
4040
},
4141
mask: {
4242
type: String,
43-
required: true
43+
required: true,
44+
validator: value => !! (value && value.length >= 1)
4445
},
4546
placeholderChar: {
4647
type: String,
47-
default: '_'
48+
default: '_',
49+
validator: value => !! (value && value.length === 1)
4850
},
4951
},
5052
@@ -95,8 +97,9 @@ export default {
9597
this.$emit('input', this.default, this.default)
9698
}
9799
catch (e) {
100+
console.error(e.message);
98101
this.mask_core = null
99-
this.$refs.input.value = '0 editable chars in mask'
102+
this.$refs.input.value = 'Error, see console'
100103
this.$emit('input', this.$refs.input.value, '')
101104
}
102105
},

src/ff-polyfill.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//https://gist.github.com/nuxodin/9250e56a3ce6c0446efa
2-
export default function () {
2+
export default () => {
33
var w = window,
44
d = w.document;
55

0 commit comments

Comments
 (0)