Skip to content

Instantly share code, notes, and snippets.

@wataruoguchi
Last active July 2, 2019 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wataruoguchi/082a584bb454666ecb28d347f834dedc to your computer and use it in GitHub Desktop.
Save wataruoguchi/082a584bb454666ecb28d347f834dedc to your computer and use it in GitHub Desktop.
// src/views/SignUpConfirm.vue
<template>
<div class="confirm">
<h1>Confirm</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="code" :rules="codeRules" label="Code" required/>
<v-btn :disabled="!valid" @click="submit">Submit</v-btn>
</v-form>
<v-btn @click="resend">Resend Code</v-btn>
</div>
</template>
<script>
export default {
name: "SignUpConfirm",
data() {
return {
valid: false,
username: '',
code: '',
}
},
computed: {
emailRules() {
return [
v => !!v || 'E-mail is required',
v => /.+@.+/.test(v) || 'E-mail must be valid'
]
},
codeRules() {
return [
v => !!v || 'Code is required',
v => (v && v.length === 6) || 'Code must be 6 digits'
]
},
},
methods: {
submit() {
if (this.$refs.form.validate()) {
console.log(`CONFIRM username: ${this.username}, code: ${this.code}`);
}
},
resend() {
console.log(`RESEND username: ${this.username}`);
}
},
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment