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 Rule For Number Between 0 And 999</h3> <v-form> <v-text-field v-model="inputValue" clearable label="Enter a number between 0 and 999 or leave it empty" :rules="numberValidation"></v-text-field> </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 { inputValue: "" }; }, computed: { numberValidation() { return [ (v) => { if (!v) return true; // Empty input is valid return /^\d{1,3}$/.test(v) && v >= 0 && v <= 999 || "Enter a number between 0 and 999"; }, ]; }, }, }); </script> </body> </html>