| | |
| | | <template> |
| | | <form @submit.prevent="submitForm"> |
| | | <div class="form-control"> |
| | | <div class="form-control" :class="{ invalid: usernameValidity === 'invalid' }"> |
| | | <label for="user-name">Your Name</label> |
| | | <input id="user-name" name="user-name" type="text" v-model="userName" /> |
| | | <input id="user-name" name="user-name" type="text" v-model.trim="userName" @blur="validateInput" /> |
| | | <p v-if="usernameValidity === 'invalid'">please enter a valid name</p> |
| | | </div> |
| | | <div class="form-control"> |
| | | <label for="age">Your Age (Years)</label> |
| | |
| | | <label for="how-other">Other</label> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="form-control"> |
| | | <rating-control> |
| | | |
| | | </rating-control> |
| | | </div> |
| | | |
| | | <div class="form-control"> |
| | | <input type="checkbox" id="confirm-terms" name="confirm-terms" v-model="confirm"> |
| | | <label for="confirm-terms">Agree to terms of use?</label> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import RatingControl from './RatingControl.vue'; |
| | | |
| | | export default { |
| | | components: { |
| | | RatingControl, |
| | | }, |
| | | data() { |
| | | return { |
| | | userName: '', |
| | |
| | | interest: [], |
| | | how: null, |
| | | confirm: false, |
| | | usernameValidity: 'pending', |
| | | } |
| | | }, |
| | | methods: { |
| | |
| | | console.log('Confirm'); |
| | | console.log(this.confirm); |
| | | this.confirm = false; |
| | | } |
| | | }, |
| | | validateInput() { |
| | | if (this.userName === '') { |
| | | this.usernameValidity = 'invalid'; |
| | | } else { |
| | | this.usernameValidity = 'valid'; |
| | | } |
| | | }, |
| | | } |
| | | |
| | | } |
| | |
| | | margin: 0.5rem 0; |
| | | } |
| | | |
| | | .form-control.invalid input { |
| | | border-color: red; |
| | | } |
| | | |
| | | .form-control.invalid label { |
| | | color: red; |
| | | } |
| | | |
| | | |
| | | label { |
| | | font-weight: bold; |
| | | } |