-
-
Save wataruoguchi/bf084ab9943ed5bfdf60b8f6edc5d5c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/views/SignIn.vue | |
<template> | |
<div class="sign-in"> | |
<h1>Sign In</h1> | |
<v-form v-model="valid" ref="form" lazy-validation> | |
<v-text-field v-model="username" :rules="emailRules" label="Email Address" required/> | |
<v-text-field | |
v-model="password" | |
:append-icon="passwordVisible ? 'visibility' : 'visibility_off'" | |
:rules="[passwordRules.required, passwordRules.min]" | |
:type="passwordVisible ? 'text' : 'password'" | |
name="password" | |
label="Password" | |
hint="At least 8 characters" | |
counter | |
@click:append="passwordVisible = !passwordVisible" | |
required/> | |
<v-btn :disabled="!valid" @click="submit">Submit</v-btn> | |
</v-form> | |
</div> | |
</template> | |
<script> | |
export default { | |
name: "SignIn", | |
data() { | |
return { | |
valid: false, | |
username: '', | |
password: '', | |
passwordVisible: false, | |
} | |
}, | |
computed: { | |
emailRules() { | |
return [ | |
v => !!v || 'E-mail is required', | |
v => /.+@.+/.test(v) || 'E-mail must be valid' | |
] | |
}, | |
passwordRules() { | |
return { | |
required: value => !!value || 'Required.', | |
min: v => v.length >= 8 || 'Min 8 characters', | |
emailMatch: () => ('The email and password you entered don\'t match'), | |
} | |
}, | |
}, | |
methods: { | |
submit() { | |
if (this.$refs.form.validate()) { | |
console.log(`SIGN IN username: ${this.username}, password: ${this.password}`); | |
} | |
}, | |
}, | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment