Guest User

Untitled

a guest
Dec 11th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. <template>
  2. ...
  3. <input type="text"
  4. v-model="fiveKmRaceTime"
  5. v-bind:class="{
  6. 'form-control': true,
  7. 'is-invalid': this.invalidRaceTime }"
  8. placeholder="A recent 5K race time, like 21:30" />
  9. <div class="invalid-feedback">{{ this.raceTimeValidationMessage }}</div>
  10. ...
  11. </template>
  12. ...
  13. <script>
  14. export default {
  15. name: 'RunbyPace',
  16. ...
  17. computed: {
  18. missingRaceTime() {
  19. return this.submitted && this.fiveKmRaceTime === '';
  20. },
  21. invalidRaceTime() {
  22. return this.missingRaceTime ||
  23. (this.submitted && !this.lib.validTime(this.fiveKmRaceTime));
  24. },
  25. raceTimeValidationMessage() {
  26. if (this.missingRaceTime) {
  27. return 'Don\'t forget your 5K race time';
  28. }
  29. if (this.invalidRaceTime) {
  30. return `'${this.fiveKmRaceTime}' is not a valid race time. Try 21:44.`;
  31. }
  32. return '5K Valid';
  33. },
  34. }
  35. ...
  36. </script>
Add Comment
Please, Sign In to add comment