screen_rotation
Copied to Clipboard
<html> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <div id="app"> <h3>Vue Js Disable input Conditionally</h3> <div class="form-group"> <label for="newPassword">Please choose a new password</label> <input type="password" class="form-control" id="newPassword" placeholder="Password" v-model="newPassword"> </div> <div class="form-group"> <label for="confirmPassword">Please confirm your new password</label> <input type="password" class="form-control" id="confirmPassword" placeholder="Password" v-model="confirmPassword" v-bind:disabled="newPassword.length === 0 ? true : false"> </div> </div> <script type="module"> const app = new Vue({ el: "#app", data() { return { newPassword: '', confirmPassword: '' }; } }); </script> <style scoped> /* Center the content */ #app { display: flex; flex-direction: column; align-items: center; } /* Style the labels */ .form-group label { display: block; margin-bottom: 5px; font-weight: bold; } /* Style the input fields */ .form-control { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; margin-bottom: 10px; } /* Style the disabled input fields */ .form-control:disabled { background-color: #f9f9f9; color: #777; } </style> </body> </html>