Commit 83236c58 authored by NikulinR's avatar NikulinR

PlaceholderChar customize added

parent 3084d376
...@@ -32,6 +32,11 @@ You can also get a raw user input text if you want. Instead of using v-model you ...@@ -32,6 +32,11 @@ You can also get a raw user input text if you want. Instead of using v-model you
<masked-input mask="+\\1 (111) 1111-11" placeholder="Phone" @input="rawVal = arguments[1]" /> <masked-input mask="+\\1 (111) 1111-11" placeholder="Phone" @input="rawVal = arguments[1]" />
``` ```
Placeholder character is customizable (`_` by default):
```vue
<masked-input v-model="phone" mask="+\\1 (111) 111-1111" placeholderChar="-" placeholder="Phone number" type="tel" />
```
## Known issues/TODO ## Known issues/TODO
* Cut in mobile Chrome * Cut in mobile Chrome
* Cyrillic chars are not supported in mobile Chrome * Cyrillic chars are not supported in mobile Chrome
......
{ {
"name": "vue-masked-input", "name": "vue-masked-input",
"description": "Masked input component for Vue.js 2.X", "description": "Masked input component for Vue.js 2.X",
"version": "0.2.3", "version": "0.2.4",
"author": "niksmr", "author": "niksmr",
"license": "MIT", "license": "MIT",
"homepage": "https://github.com/niksmr/vue-masked-input", "homepage": "https://github.com/niksmr/vue-masked-input",
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<li># – alphanumeric, forced to upper case when entered</li> <li># – alphanumeric, forced to upper case when entered</li>
</ul> </ul>
<h4>Date: </h4> <h4>Date: </h4>
<masked-input v-model="date" mask="11 / 11 / 1111" placeholder="Date"/><span v-if="">{{ date }}</span> <masked-input v-model="date" mask="11 / 11 / 1111" placeholder="Date"/><span>{{ date }}</span>
<p class="code"> <p class="code">
&lt;masked-input v-model="date" mask="11 / 11 / 1111" placeholder="Date" /&gt; &lt;masked-input v-model="date" mask="11 / 11 / 1111" placeholder="Date" /&gt;
</p> </p>
......
...@@ -40,11 +40,13 @@ export default { ...@@ -40,11 +40,13 @@ export default {
}, },
mask: { mask: {
type: String, type: String,
required: true required: true,
validator: value => !! (value && value.length >= 1)
}, },
placeholderChar: { placeholderChar: {
type: String, type: String,
default: '_' default: '_',
validator: value => !! (value && value.length === 1)
}, },
}, },
...@@ -95,8 +97,9 @@ export default { ...@@ -95,8 +97,9 @@ export default {
this.$emit('input', this.default, this.default) this.$emit('input', this.default, this.default)
} }
catch (e) { catch (e) {
console.error(e.message);
this.mask_core = null this.mask_core = null
this.$refs.input.value = '0 editable chars in mask' this.$refs.input.value = 'Error, see console'
this.$emit('input', this.$refs.input.value, '') this.$emit('input', this.$refs.input.value, '')
} }
}, },
......
//https://gist.github.com/nuxodin/9250e56a3ce6c0446efa //https://gist.github.com/nuxodin/9250e56a3ce6c0446efa
export default function () { export default () => {
var w = window, var w = window,
d = w.document; d = w.document;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment