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

@@ -1,28 +1,45 @@
<template>
<div class="LoginForm">
<h2>Login</h2>
<form @submit.prevent="login">
<label>Username:</label><input type="text" v-model="username"><br>
<label>Password:</label><input type="password" v-model="password"><br>
<input type="submit" value="login">
</form>
<my-form :elements="elements" :buttons="buttons" :submitHandler="login"></my-form>
</div>
</template>
<script>
import Axios from 'axios';
import MyForm from '../my-form.vue';
export default {
name: 'LoginForm',
components: {
MyForm
},
data() {
return {
username: '',
password: ''
password: '',
elements: {
username: {
label: 'Benutzername',
type: 'text',
required: true
},
password: {
label: 'Passwort',
type: 'password',
required: true
}
},
buttons: [
{
label: 'login',
type: 'submit'
}
]
}
},
methods: {
login() {
this.$store.dispatch("login", this.$data)
login(formData) {
this.$store.dispatch("login", formData)
.then(user => {
console.log("---- user login --------");
console.log(user);