screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <script src="https://unpkg.com/vue@3.2.22/dist/vue.global.js"></script> </head> <body> <div id="app"> <h3> Vue Js check empty String and Space</h3> <input type="text" v-model="myString" @input="checkString" /> <p>{{output}}</p> </div> <script type="module"> const app = Vue.createApp({ data() { return { myString: "", output: '' }; }, methods: { checkString() { if (!this.myString || /^\s*$/.test(this.myString)) { this.output = "String is empty or contains only spaces!"; } else { this.output = "String contains some content!"; } } } }) app.mount('#app') </script> <style scoped> #app { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; } input[type="text"] { padding: 10px; font-size: 16px; border: 2px solid #ccc; border-radius: 5px; margin-bottom: 10px; } p { font-size: 20px; color: #333; } </style> </body> </html>