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"> <script src="https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.js"></script> <script src="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.js"></script> <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 Validate Textarea Character Limit</h3> <v-form @submit="submitForm"> <v-textarea v-model="text" :counter="counter" :rules="[validateTextArea]" label="Text Area (Optional, Max 50 characters)"></v-textarea> <v-btn type="submit" color="primary">Submit</v-btn> </v-form> </v-container> </v-main> </v-app> </div> <script> new Vue({ el: '#app', vuetify: new Vuetify(), data() { return { text: '', // Initialize the text variable counter: 0, // Initialize the character count }; }, methods: { validateTextArea() { if (this.text.length > 0 && this.text.length <= 50) { return true; // Validation passes } else { return 'Text must be 1 to 50 characters'; // Validation fails } }, submitForm() { // Handle form submission here // Only if the text area is valid (1 to 200 characters) }, }, }) </script> </body> </html>