Browse Source

login ui changes

Naresh Ch 2 years ago
parent
commit
1ee03d2ecc
4 changed files with 63 additions and 36 deletions
  1. 2
    1
      assets/css/login.css
  2. 3
    3
      assets/js/common.js
  3. 49
    24
      assets/js/login.js
  4. 9
    8
      login/index.html

+ 2
- 1
assets/css/login.css View File

113
     color: #d93025;
113
     color: #d93025;
114
 }
114
 }
115
 
115
 
116
-.biz-login-wrap .password-fixed {
116
+.biz-login-wrap .form-group label.password-fixed {
117
     transform: translate3d(0, -175%, 0);
117
     transform: translate3d(0, -175%, 0);
118
     z-index: 1 !important;
118
     z-index: 1 !important;
119
     color: #1a73e8;
119
     color: #1a73e8;
187
 .biz-login-wrap .password-checkbox {
187
 .biz-login-wrap .password-checkbox {
188
     width: 20px;
188
     width: 20px;
189
     height: 20px;
189
     height: 20px;
190
+    margin-right: 5px;
190
 }
191
 }
191
 
192
 
192
 .biz-login-wrap .show-password-link {
193
 .biz-login-wrap .show-password-link {

+ 3
- 3
assets/js/common.js View File

1
 const serverUrl = 'http://localhost:3088/';
1
 const serverUrl = 'http://localhost:3088/';
2
 
2
 
3
 function getCookie(name) {
3
 function getCookie(name) {
4
-  var nameEQ = name + '=';
5
-  var ca = document.cookie.split(';');
4
+  const nameEQ = name + '=';
5
+  const ca = document.cookie.split(';');
6
   for (var i = 0; i < ca.length; i++) {
6
   for (var i = 0; i < ca.length; i++) {
7
-    var c = ca[i];
7
+    const c = ca[i];
8
     while (c.charAt(0) == ' ') c = c.substring(1, c.length);
8
     while (c.charAt(0) == ' ') c = c.substring(1, c.length);
9
     if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
9
     if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
10
   }
10
   }

+ 49
- 24
assets/js/login.js View File

3
 const passwordInputEl = document.getElementById('password');
3
 const passwordInputEl = document.getElementById('password');
4
 const emailErrEl = document.getElementById('emailErrMsg');
4
 const emailErrEl = document.getElementById('emailErrMsg');
5
 const passwordErrEl = document.getElementById('passwordErrMsg');
5
 const passwordErrEl = document.getElementById('passwordErrMsg');
6
+const emailContainerEl = document.getElementById('emailBox');
7
+const passwordContainerEl = document.getElementById('passwordBox');
8
+const showPasswordChk = document.getElementById('showPassword');
9
+const emailNextBtn = document.getElementById('emailNextBtn');
10
+const renterEmailLink = document.getElementById('renterEmail');
11
+const loginSubmitBtn = document.getElementById('loginSubmitBtn');
6
 
12
 
7
-document.getElementById('passwordBox').style.display = 'none';
13
+passwordContainerEl.style.display = 'none';
14
+emailInputEl.focus();
8
 
15
 
9
 function showPasswordBox() {
16
 function showPasswordBox() {
10
   const email = emailInputEl.value;
17
   const email = emailInputEl.value;
11
-  if (email.includes('@')) {
12
-    document.getElementById('emailBox').style.display = 'none';
13
-    document.getElementById('passwordBox').style.display = 'block';
18
+  if (validateEmailOrPhone()) {
19
+    emailContainerEl.style.display = 'none';
20
+    passwordContainerEl.style.display = 'block';
14
     document.getElementById('entered-email').innerHTML = email;
21
     document.getElementById('entered-email').innerHTML = email;
22
+    passwordInputEl.focus();
15
     emailInputEl.classList.remove('error');
23
     emailInputEl.classList.remove('error');
16
     emailErrEl.innerText = '';
24
     emailErrEl.innerText = '';
17
   } else {
25
   } else {
18
     emailInputEl.classList.add('error');
26
     emailInputEl.classList.add('error');
19
-    emailErrEl.innerText = 'Please enter valid email';
27
+    emailErrEl.innerText = 'Please enter valid email or phone';
20
   }
28
   }
21
 }
29
 }
22
 
30
 
31
+function validateEmailOrPhone() {
32
+  const value = emailInputEl.value.trim();
33
+  const regx = /^[6-9]\d{9}$/;
34
+  if (value.includes('@') || regx.test(value)) {
35
+    return true;
36
+  }
37
+  return false;
38
+}
39
+
23
 function togglePassword() {
40
 function togglePassword() {
24
   const ele = document.getElementById('showPassword');
41
   const ele = document.getElementById('showPassword');
25
   const password = passwordInputEl;
42
   const password = passwordInputEl;
35
   }
52
   }
36
 }
53
 }
37
 
54
 
38
-function onPasswordFocus() {
55
+function onPasswordFocusOut() {
56
+  const passwordLabel = document.getElementById('passwordLabel');
39
   if (passwordInputEl.value.length > 0) {
57
   if (passwordInputEl.value.length > 0) {
40
-    document.getElementById('password-label').classList.add('password-fixed');
58
+    passwordLabel.classList.add('password-fixed');
59
+  } else {
60
+    passwordLabel.classList.remove('password-fixed');
61
+  }
62
+}
63
+
64
+function onEmailFocusOut() {
65
+  const emailLabel = document.getElementById('emailLabel');
66
+  if (emailInputEl.value.trim()) {
67
+    emailLabel.classList.add('password-fixed');
41
   } else {
68
   } else {
42
-    document
43
-      .getElementById('password-label')
44
-      .classList.remove('password-fixed');
69
+    emailLabel.classList.remove('password-fixed');
45
   }
70
   }
46
 }
71
 }
47
 
72
 
91
 function validateLogin() {
116
 function validateLogin() {
92
   const email = emailInputEl.value;
117
   const email = emailInputEl.value;
93
   const password = passwordInputEl.value;
118
   const password = passwordInputEl.value;
94
-  if (email.includes('@') && password.trim().length !== 0) {
119
+  if (password.trim().length !== 0) {
95
     loginUser(email, password);
120
     loginUser(email, password);
96
-  } else if (!email.includes('@')) {
97
-    emailErrEl.innerHTML = 'Please enter valid email';
98
   } else {
121
   } else {
99
     passwordInputEl.classList.add('error');
122
     passwordInputEl.classList.add('error');
100
     passwordErrEl.innerText = 'Please enter valid password';
123
     passwordErrEl.innerText = 'Please enter valid password';
102
 }
125
 }
103
 
126
 
104
 function initializeEventListeners() {
127
 function initializeEventListeners() {
105
-  document.getElementById('emailNextBtn').addEventListener('click', () => {
106
-    showPasswordBox();
107
-  });
128
+  document
129
+    .getElementById('emailNextBtn')
130
+    .addEventListener('click', showPasswordBox);
108
 
131
 
109
-  document.getElementById('showPassword').addEventListener('click', () => {
110
-    togglePassword();
111
-  });
132
+  showPasswordChk.addEventListener('click', togglePassword);
112
 
133
 
113
-  document.getElementById('showPassword').addEventListener('onfocusout', () => {
114
-    onPasswordFocus();
115
-  });
134
+  passwordInputEl.addEventListener('focusout', onPasswordFocusOut);
135
+
136
+  emailInputEl.addEventListener('focusout', onEmailFocusOut);
137
+
138
+  loginSubmitBtn.addEventListener('click', validateLogin);
116
 
139
 
117
-  document.getElementById('loginSubmitBtn').addEventListener('click', () => {
118
-    validateLogin();
140
+  renterEmailLink.addEventListener('click', () => {
141
+    emailContainerEl.style.display = 'block';
142
+    passwordContainerEl.style.display = 'none';
143
+    emailInputEl.focus();
119
   });
144
   });
120
 }
145
 }
121
 
146
 

+ 9
- 8
login/index.html View File

22
                     <div class="form-input-wrap">
22
                     <div class="form-input-wrap">
23
                         <div class="form-group">
23
                         <div class="form-group">
24
                             <input type="text" id="email" class="email-input">
24
                             <input type="text" id="email" class="email-input">
25
-                            <label class="form-control-placeholder" for="name">Email or phone</label>
25
+                            <label class="form-control-placeholder" id="emailLabel" for="email">Email or phone</label>
26
                         </div>
26
                         </div>
27
                         <div class="err-msg" id="emailErrMsg"></div>
27
                         <div class="err-msg" id="emailErrMsg"></div>
28
                         <div class="form-link mt-10">
28
                         <div class="form-link mt-10">
49
                 <div class="form-body password-form-box">
49
                 <div class="form-body password-form-box">
50
                     <div class="form-input-wrap">
50
                     <div class="form-input-wrap">
51
                         <div class="form-group">
51
                         <div class="form-group">
52
-                            <input type="password" id="password" class="password-input"
53
-                                onfocus="this.value = this.value;">
54
-                            <label class="form-control-placeholder" id="password-label" for="name">Enter Your
52
+                            <input type="password" id="password" class="password-input">
53
+                            <label class="form-control-placeholder" id="passwordLabel" for="password">Enter Your
55
                                 Password</label>
54
                                 Password</label>
56
                         </div>
55
                         </div>
57
                         <div class="err-msg" id="passwordErrMsg"></div>
56
                         <div class="err-msg" id="passwordErrMsg"></div>
58
-                        <div class="form-link show-password-link">
59
-                            <input type="checkbox" id="showPassword" class="password-checkbox">
60
-                            <label for="showPassword">Show password</label>
57
+                        <div class="form-link show-password-link flex-between-center">
58
+                            <div class="flex-between-center"><input type="checkbox" id="showPassword"
59
+                                    class="password-checkbox">
60
+                                <label for="showPassword">Show password</label></div>
61
+                            <label><a href="../forgotpassword">Forgot password?</a></label>
61
                         </div>
62
                         </div>
62
                     </div>
63
                     </div>
63
                     <div class="form-link flex-between-center">
64
                     <div class="form-link flex-between-center">
64
-                        <label><a href="../forgotpassword">Forgot password?</a></label>
65
+                        <label><a href="javascript:;" id="renterEmail">Reenter email?</a></label>
65
                         <button class="btn" id="loginSubmitBtn">Submit</button>
66
                         <button class="btn" id="loginSubmitBtn">Submit</button>
66
                     </div>
67
                     </div>
67
                 </div>
68
                 </div>

Loading…
Cancel
Save