screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/@mdi/font@6.x/css/materialdesignicons.min.css" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css" rel="stylesheet"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui"> </head> <body> <div id="app"> <v-app> <v-main> <v-container> <h3>Vuetify set Confirm Password Validation Rule in text-fields</h3> <v-form @submit.prevent="register"> <v-text-field label="Password" clearable v-model="password" type="password" :rules="passwordRules"></v-text-field> <v-text-field label="Confirm Password" clearable v-model="confirmPassword" type="password" :rules="confirmPasswordRules"></v-text-field> <v-btn type="submit" color="primary">Register</v-btn> </v-form> </v-container> </v-main> </v-app> </div> <script src="https://cdn.jsdelivr.net/npm/vue@2.x"></script> <script src="https://cdn.jsdelivr.net/npm/vuetify@2.x"></script> <script> new Vue({ el: '#app', vuetify: new Vuetify(), data() { return { password: "", confirmPassword: "", }; }, methods: { register() { // Perform registration logic here }, }, computed: { passwordRules() { return [ (v) => !!v || "Password is required", (v) => v && v.length >= 8 || "Password must be at least 8 characters", ]; }, confirmPasswordRules() { return [ (v) => !!v || "Confirm Password is required", (v) => v === this.password || "Passwords do not match", ]; }, }, }); </script> </body> </html>