Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <template>
- <div class="signup">
- <h2 v-on:click="displaySignup" id="signup-title">Sign up!</h2>
- <div v-if="!hidden" id="form-container">
- <form v-on:submit="formSub" action="#" id="signup-form">
- <span v-on:click="hidden = true" id="signup-exit">Not now</span>
- <input type="text" v-model="username" placeholder="Username" id="username-input" class="signup-input">
- <span v-if="nameErr" class="signup-error">Please enter a username</span>
- <input type="email" v-model="email" placeholder="Email" id="email-input" class="signup-input">
- <span v-if="emailErr" class="signup-error">Please enter your email address</span>
- <input type="email" v-model="emailConfirm" placeholder="Confirm Email" id="email-confirm" class="signup-input">
- <span v-if="emailMatchErr" class="signup-error">Email does not match</span>
- <input type="password" v-model="password" placeholder="Password" id="password-input" class="signup-input">
- <span v-if="passwordErr" class="signup-error">Please enter a password</span>
- <input type="password" v-model="passwordConfirm" placeholder="Confirm Password" id="password-confirm" class="signup-input">
- <span v-if="passwordMatchErr" class="signup-error">Password does not match</span>
- <button type="submit" id="form-submit">Go!</button>
- </form>
- </div>
- </div>
- </template>
- <script>
- export default {
- name: 'signup',
- data () {
- return {
- hidden: true,
- username: '',
- email: '',
- emailConfirm: '',
- password: '',
- passwordConfirm: '',
- nameErr: false,
- emailErr: false,
- emailMatchErr: false,
- passwordErr: false,
- passwordMatchErr: false
- }
- },
- methods: {
- formSub: function(e) {
- if(this.username == "") {
- e.preventDefault();
- this.nameErr = true;
- }
- else if(this.email == "") {
- e.preventDefault();
- this.emailErr = true;
- }
- else if(this.email != this.emailConfirm) {
- e.preventDefault();
- this.emailMatchErr = true;
- }
- else if(this.password == "") {
- e.preventDefault();
- this.passwordErr = true;
- }
- else if(this.password != this.passwordConfirm) {
- e.preventDefault();
- this.passwordMatchErr;
- }
- else {
- e.preventDefault();
- this.username = '';
- this.email = '';
- this.emailConfirm = '';
- this.password = '';
- this.paswordConfirm = ''
- //Call to backend goes here
- }
- },
- displaySignup: function() {
- this.nameErr = false;
- this.emailErr = false;
- this.emailMatchErr = false;
- this.passwordErr = false;
- this.passwordMatchErr = false;
- this.hidden = false;
- }
- }
- }
- </script>
- <style scoped>
- #signup-title {
- cursor: pointer;
- }
- #signup-exit {
- cursor: pointer;
- text-align: right;
- }
- #form-container {
- height: 520px;
- width: 370px;
- box-shadow: 0px 0px 7px 2px grey;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- border-radius: 5px;
- position: absolute;
- background-color: white;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .signup-input {
- display: flex;
- width: 250px;
- height: 50px;
- margin: 0 auto;
- margin-bottom: 5px;
- text-align: center;
- font-size: 1.6em;
- }
- .signup-error {
- color: red;
- }
- #form-submit {
- display: block;
- margin: 0 auto;
- background-color: white;
- width: 150px;
- height: 50px;
- font-size: 1.6em;
- border: none;
- cursor: pointer;
- }
- </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement