validate input fields
This commit is contained in:
34
src/components/my-input.vue
Normal file
34
src/components/my-input.vue
Normal file
@@ -0,0 +1,34 @@
|
||||
<template>
|
||||
<div class="My-Input">
|
||||
<label>{{ label }}</label>
|
||||
<input type="text" v-if="type == 'text'" v-model="currentValue" @blur="validate()">
|
||||
<input type="password" v-else-if="type == 'password'" v-model="currentValue" @blur="validate()">
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "MyInput",
|
||||
props: [
|
||||
'label',
|
||||
'type',
|
||||
'name',
|
||||
'value'
|
||||
],
|
||||
data() {
|
||||
return {
|
||||
currentValue: this.value
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
validate() {
|
||||
this.$emit('validate', this.currentValue);
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
currentValue(val) {
|
||||
this.$emit('input', val);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user