-
-
Save wataruoguchi/382968b8bc4f58411c70d30a77b872b0 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/SignUp.vue | |
<template> | |
<div class="sign-up"> | |
<h1>Sign Up</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: "SignUp", | |
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 UP username: ${this.username}, password: ${this.password}, email: ${this.username}`); | |
} | |
}, | |
}, | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment