screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html lang="en"> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <div id="app"> <label for="password">Password:</label> <div> <input type="text" v-bind:type="showPassword ? 'text' : 'password'" id="password" v-model="password" @input="validatePassword" /> <button @click="showPassword = !showPassword">{{ showPassword ? 'Hide':'Show' }}</Fbutton> </div> <span v-if="showValidationMessage">{{ validationMessage }}</span> </div> <script type="module"> const app = new Vue({ el: "#app", data() { return { password: '', showValidationMessage: false, validationMessage: '', showPassword: false }; }, methods: { validatePassword() { const passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/ if (!this.password) { this.showValidationMessage = false; return; } if (passwordRegex.test(this.password)) { this.showValidationMessage = false; } else { this.showValidationMessage = true; this.validationMessage = 'Password must contain at least one letter and one digit, and is at least 8 characters long'; } }, } }); </script> <style scoped> #app { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; } label { font-weight: bold; margin-bottom: 8px; } input { padding: 8px; border-radius: 4px; border: 1px solid #ccc; margin-bottom: 16px; } button { background-color: #4caf50; color: white; padding: 8px 16px; border: none; border-radius: 4px; cursor: pointer; margin-left: 8px; } button:hover { background-color: #3e8e41; } span { color: red; margin-top: 8px; } </style> </body> </html>