validate input fields
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user