validate input fields

This commit is contained in:
Sebastian Frank
2017-08-24 22:12:56 +02:00
parent 55144f7657
commit 2ef22fd197
3 changed files with 146 additions and 9 deletions

View 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>