Commit 05d17c5c by liwk

commit

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