Advertisement
Guest User

Untitled

a guest
Sep 17th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. <template>
  2. <div class="signup">
  3. <h2 v-on:click="displaySignup" id="signup-title">Sign up!</h2>
  4. <div v-if="!hidden" id="form-container">
  5. <form v-on:submit="formSub" action="#" id="signup-form">
  6. <span v-on:click="hidden = true" id="signup-exit">Not now</span>
  7. <input type="text" v-model="username" placeholder="Username" id="username-input" class="signup-input">
  8. <span v-if="nameErr" class="signup-error">Please enter a username</span>
  9. <input type="email" v-model="email" placeholder="Email" id="email-input" class="signup-input">
  10. <span v-if="emailErr" class="signup-error">Please enter your email address</span>
  11. <input type="email" v-model="emailConfirm" placeholder="Confirm Email" id="email-confirm" class="signup-input">
  12. <span v-if="emailMatchErr" class="signup-error">Email does not match</span>
  13. <input type="password" v-model="password" placeholder="Password" id="password-input" class="signup-input">
  14. <span v-if="passwordErr" class="signup-error">Please enter a password</span>
  15. <input type="password" v-model="passwordConfirm" placeholder="Confirm Password" id="password-confirm" class="signup-input">
  16. <span v-if="passwordMatchErr" class="signup-error">Password does not match</span>
  17. <button type="submit" id="form-submit">Go!</button>
  18. </form>
  19. </div>
  20. </div>
  21. </template>
  22.  
  23. <script>
  24. export default {
  25. name: 'signup',
  26. data () {
  27. return {
  28. hidden: true,
  29. username: '',
  30. email: '',
  31. emailConfirm: '',
  32. password: '',
  33. passwordConfirm: '',
  34. nameErr: false,
  35. emailErr: false,
  36. emailMatchErr: false,
  37. passwordErr: false,
  38. passwordMatchErr: false
  39. }
  40. },
  41. methods: {
  42. formSub: function(e) {
  43. if(this.username == "") {
  44. e.preventDefault();
  45. this.nameErr = true;
  46. }
  47. else if(this.email == "") {
  48. e.preventDefault();
  49. this.emailErr = true;
  50. }
  51. else if(this.email != this.emailConfirm) {
  52. e.preventDefault();
  53. this.emailMatchErr = true;
  54. }
  55. else if(this.password == "") {
  56. e.preventDefault();
  57. this.passwordErr = true;
  58. }
  59. else if(this.password != this.passwordConfirm) {
  60. e.preventDefault();
  61. this.passwordMatchErr;
  62. }
  63. else {
  64. e.preventDefault();
  65. this.username = '';
  66. this.email = '';
  67. this.emailConfirm = '';
  68. this.password = '';
  69. this.paswordConfirm = ''
  70. //Call to backend goes here
  71. }
  72. },
  73. displaySignup: function() {
  74. this.nameErr = false;
  75. this.emailErr = false;
  76. this.emailMatchErr = false;
  77. this.passwordErr = false;
  78. this.passwordMatchErr = false;
  79. this.hidden = false;
  80. }
  81. }
  82. }
  83. </script>
  84.  
  85. <style scoped>
  86. #signup-title {
  87. cursor: pointer;
  88. }
  89.  
  90. #signup-exit {
  91. cursor: pointer;
  92. text-align: right;
  93. }
  94.  
  95. #form-container {
  96. height: 520px;
  97. width: 370px;
  98. box-shadow: 0px 0px 7px 2px grey;
  99. top: 50%;
  100. left: 50%;
  101. transform: translate(-50%, -50%);
  102. border-radius: 5px;
  103. position: absolute;
  104. background-color: white;
  105. display: flex;
  106. justify-content: center;
  107. align-items: center;
  108. }
  109.  
  110. .signup-input {
  111. display: flex;
  112. width: 250px;
  113. height: 50px;
  114. margin: 0 auto;
  115. margin-bottom: 5px;
  116. text-align: center;
  117. font-size: 1.6em;
  118. }
  119.  
  120. .signup-error {
  121. color: red;
  122. }
  123.  
  124. #form-submit {
  125. display: block;
  126. margin: 0 auto;
  127. background-color: white;
  128. width: 150px;
  129. height: 50px;
  130. font-size: 1.6em;
  131. border: none;
  132. cursor: pointer;
  133. }
  134. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement