Commit 05d17c5c by liwk

commit

1 parent e7a7e286
...@@ -40,6 +40,9 @@ export default { ...@@ -40,6 +40,9 @@ export default {
error: { error: {
type: Boolean, type: Boolean,
default: false default: false
},
pattern: {
type: RegExp
} }
}, },
watch: { watch: {
...@@ -67,8 +70,9 @@ export default { ...@@ -67,8 +70,9 @@ export default {
} }
}, },
input (index) { input (index) {
this.values[index] = this.values[index].substring(0, 1) let { length, pattern } = this
let { length } = this this.values[index] = pattern.test(this.values[index]) ? this.values[index].substring(0, 1) : ''
if (index < length - 1 && this.values[index]) this.$refs[`focus-${index + 1}`][0].focus() if (index < length - 1 && this.values[index]) this.$refs[`focus-${index + 1}`][0].focus()
} }
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
:value="value" :value="value"
@input="input" @input="input"
:error="error" :error="error"
:pattern="/^[A-Za-z0-9]+$/"
></input-group> ></input-group>
<div <div
class="err-box" class="err-box"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!