screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> </head> <body> <div id="app"> <h3>Vue Js Textbox allow ony capital letter</h3> <input type="text" v-model="inputValue" @input="handleInput" /> <div v-if="!isInputValid" class="error-message">Only capital letters are allowed.</div> </div> <script> const app = Vue.createApp({ data() { return { inputValue: "", isInputValid: true }; }, methods: { handleInput() { // Check if the input consists of only capital letters this.isInputValid = /^[A-Z]*$/.test(this.inputValue); // Remove any non-capital letters from the input this.inputValue = this.inputValue.replace(/[^A-Z]/g, ""); } } }); app.mount('#app'); </script> <style> #app { width: 400px; margin: 0 auto; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.12), 0 2px 4px 0 rgba(0, 0, 0, 0.24); text-align: center; padding: 20px; height: 100%; } .error-message { color: red; font-size: 14px; margin-top: 5px; } input[type="text"] { padding: 10px; font-size: 16px; border: 1px solid #ccc; border-radius: 4px; outline-color: blue; /* Change the color as desired */ } </style> </body> </html>