Dooratre commited on
Commit
f598023
1 Parent(s): 04cdf45

Update templates/sign-up.html

Browse files
Files changed (1) hide show
  1. templates/sign-up.html +125 -89
templates/sign-up.html CHANGED
@@ -110,107 +110,143 @@
110
  }
111
  </style>
112
  <style>
113
- .success-message {
114
- color: green;
115
- border: 2px solid green;
116
- padding: 10px;
117
- margin-bottom: 10px;
118
- }
119
-
120
- .error-message {
121
- color: red;
122
- border: 2px solid red;
123
- padding: 10px;
124
- margin-bottom: 10px;
125
- }
126
  </style>
127
  <body>
128
  <!--$-->
129
  <div class="techwave_fn_sign">
130
- <div class="sign__content">
131
- <h1 class="logo">Designed by Frenify</h1>
132
- <form class="signup" method="POST" action="/sign-up" onsubmit="return validateForm()" enctype="multipart/form-data">
133
- <div class="form__content">
134
- {% with messages = get_flashed_messages() %}
135
- {% if messages %}
136
- <ul>
137
- {% for message in messages %}
138
- <li>{{ message }}</li>
139
- {% endfor %}
140
- </ul>
141
- {% endif %}
142
- {% endwith %}
143
-
144
- <div class="form__title">Sign Up</div>
145
- <br>
146
- {% with messages = get_flashed_messages() %}
147
- {% if messages %}
148
- <ul>
149
  {% for message in messages %}
150
- <li>{{ message }}</li>
 
 
 
 
 
 
151
  {% endfor %}
152
- </ul>
153
- {% endif %}
154
- {% endwith %}
155
- <div class="form__username">
156
- <label for="username">First Name</label>
157
- <input type="text" class="input" id="first_name" name="first_name" placeholder="Username" required />
158
- </div>
159
- <div class="form__username">
160
- <label for="username">Last Nmae</label>
161
- <input type="text" class="input" id="last_name" name="last_name" placeholder="Username" required />
162
- </div>
163
- <div class="form__username">
164
- <label for="username">Username</label>
165
- <input type="text" class="input" id="username" name="username" placeholder="Username" required />
166
- </div>
167
- <div class="form__pass">
168
- <label for="user_password">Password</label>
169
- <input type="password" id="password" name="password" autoComplete="current-password" spellCheck="false" placeholder="Strong password" required />
170
- </div>
171
- <div class="form__confirm-pass">
172
- <label for="confirm_password">Confirm Password</label>
173
- <input type="password" id="confirm_password" name="confirm_password" autoComplete="current-password" spellCheck="false" placeholder="Confirm password" required />
174
- </div>
175
- <br>
176
- <div class="input-div">
177
- <input class="input2" type="file" id="profile_image" name="profile_image" required>
178
- <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" stroke-linejoin="round" stroke-linecap="round" viewBox="0 0 24 24" stroke-width="2" fill="none" stroke="currentColor" class="icon"><polyline points="16 16 12 12 8 16"></polyline><line y2="21" x2="12" y1="12" x1="12"></line><path d="M20.39 18.39A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.3"></path><polyline points="16 16 12 12 8 16"></polyline></svg>
179
- </div>
180
- <br>
181
- <P>Upload Your For Profile</P>
182
- <br>
183
- <div class="form__submit">
184
- <label class="fn__submit">
185
- <input type="submit" name="submit" value="Create Account" onclick="return validateForm()" />
186
- </label>
187
- </div>
188
- <div class="form__alternative ">
189
- <div class="fn__lined_text">
190
- </div>
191
  </div>
192
-
193
- <script>
 
194
  function validateForm() {
195
- var password = document.getElementById("password").value;
196
- var confirm_password = document.getElementById("confirm_password").value;
 
 
 
197
 
198
- if (password !== confirm_password) {
199
- var errorMessage = document.createElement("p");
200
- errorMessage.className = "error-message";
201
- errorMessage.innerHTML = "Passwords do not match";
202
 
203
- var confirmPassField = document.getElementById("confirm_password");
204
- confirmPassField.insertAdjacentElement("afterend", document.createElement("br"));
205
- confirmPassField.insertAdjacentElement("afterend", errorMessage);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
 
207
- return false;
208
- }
209
- return true;
210
- } </script>
211
- <div class="sign__desc">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
 
213
- <p>Already have an account? <a href="/">Sign In</a></p>
214
  </div>
215
  </div>
216
  </div>
 
110
  }
111
  </style>
112
  <style>
113
+ .error-message {
114
+ color: red;
115
+ border: 1px solid red;
116
+ padding: 10px;
117
+ list-style: none;
118
+ }
119
+
120
+ .success-message {
121
+ color: green;
122
+ border: 1px solid green;
123
+ padding: 10px;
124
+ list-style: none;
125
+ }
126
  </style>
127
  <body>
128
  <!--$-->
129
  <div class="techwave_fn_sign">
130
+ <div class="sign__content">
131
+ <img src="desine/img/logo-desktop-full.png">
132
+ <br>
133
+ <h1 class="logo">Designed by Frenify</h1>
134
+ <form class="signup" method="POST" action="/sign-up" onsubmit="return validateForm()" enctype="multipart/form-data">
135
+ <div class="form__content">
136
+ <h1 class="logo">Designed by Frenify</h1>
137
+ <br>
138
+
139
+ {% with messages = get_flashed_messages() %}
140
+ {% if messages %}
141
+ <ul>
 
 
 
 
 
 
 
142
  {% for message in messages %}
143
+ {% if message == "Username is already taken. Please choose a different username." %}
144
+ <li class="error-message">{{ message }}</li>
145
+ {% elif message == "Failed to upload image to DataBase." %}
146
+ <li class="error-message">{{ message }}</li>
147
+ {% else %}
148
+
149
+ {% endif %}
150
  {% endfor %}
151
+ </ul>
152
+ {% endif %}
153
+ {% endwith %}
154
+ <div class="form__username">
155
+ <label for="first_name">First Name</label>
156
+ <input type="text" class="input" id="first_name" name="first_name" placeholder="First Name" required />
157
+ </div>
158
+ <div class="form__username">
159
+ <label for="last_name">Last Name</label>
160
+ <input type="text" class="input" id="last_name" name="last_name" placeholder="Last Name" required />
161
+ </div>
162
+ <div class="form__username">
163
+ <label for="username">Username</label>
164
+ <input type="text" class="input" id="username" name="username" placeholder="Username" required />
165
+ </div>
166
+ <div class="form__pass">
167
+ <label for="password">Password</label>
168
+ <input type="password" id="password" name="password" autoComplete="current-password" spellCheck="false" placeholder="password" required />
169
+ </div>
170
+ <div class="form__confirm-pass">
171
+ <label for="confirm_password">Confirm Password</label>
172
+ <input type="password" id="confirm_password" name="confirm_password" autoComplete="current-password" spellCheck="false" placeholder="Confirm password" required />
173
+ </div>
174
+ <br>
175
+ <div class="input-div">
176
+ <input class="input2" type="file" id="profile_image" name="profile_image" required onchange="displayImageName()">
177
+ <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" stroke-linejoin="round" stroke-linecap="round" viewBox="0 0 24 24" stroke-width="2" fill="none" stroke="currentColor" class="icon"><polyline points="16 16 12 12 8 16"></polyline><line y2="21" x2="12" y1="12" x1="12"></line><path d="M20.39 18.39A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.3"></path><polyline points="16 16 12 12 8 16"></polyline></svg>
178
+ </div>
179
+ <br>
180
+ <p class="file-message" id="file-message">Please upload an image for your profile</p>
181
+ <br>
182
+ <div class="form__submit">
183
+ <label class="fn__submit">
184
+ <input type="submit" name="submit" value="Create Account" />
185
+ </label>
186
+ </div>
187
+ <div class="form__alternative ">
188
+ <div class="fn__lined_text">
 
189
  </div>
190
+ </div>
191
+
192
+ <script>
193
  function validateForm() {
194
+ var password = document.getElementById("password").value;
195
+ var confirm_password = document.getElementById("confirm_password").value;
196
+ var username = document.getElementById("username").value;
197
+ var passwordErrorMessage = document.createElement("p");
198
+ var usernameErrorMessage = document.createElement("p");
199
 
200
+ passwordErrorMessage.className = "error-message";
201
+ usernameErrorMessage.className = "error-message";
 
 
202
 
203
+ // Clear previous error messages
204
+ var errorMessages = document.querySelectorAll(".error-message");
205
+ errorMessages.forEach(function(message) {
206
+ message.remove();
207
+ });
208
+
209
+ // Password validation
210
+ if (password.length < 8 || !/[A-Z]/.test(password)) {
211
+ passwordErrorMessage.innerHTML = "Password must be at least 8 characters long and contain at least one capital letter.";
212
+ var passwordField = document.getElementById("password");
213
+ passwordField.insertAdjacentElement("afterend", passwordErrorMessage);
214
+ return false;
215
+ }
216
+
217
+ if (password !== confirm_password) {
218
+ var confirmPassField = document.getElementById("confirm_password");
219
+ var confirmErrorMessage = document.createElement("p");
220
+ confirmErrorMessage.className = "error-message";
221
+ confirmErrorMessage.innerHTML = "Passwords do not match.";
222
+ confirmPassField.insertAdjacentElement("afterend", confirmErrorMessage);
223
+ return false;
224
+ }
225
 
226
+ // Username validation
227
+ if (username.length < 6 || /[A-Z]/.test(username) || /[^a-z0-9]/.test(username)) {
228
+ usernameErrorMessage.innerHTML = "Username must be at least 6 characters long, contain no capital letters, and contain no special symbols.";
229
+ var usernameField = document.getElementById("username");
230
+ usernameField.insertAdjacentElement("afterend", usernameErrorMessage);
231
+ return false;
232
+ }
233
+
234
+ return true;
235
+ }
236
+
237
+ function displayImageName() {
238
+ var input = document.getElementById('profile_image');
239
+ var fileMessage = document.getElementById('file-message');
240
+
241
+ if (input.files && input.files[0]) {
242
+ fileMessage.innerText = "Uploaded file: " + input.files[0].name;
243
+ } else {
244
+ fileMessage.innerText = "Please upload an image for your profile";
245
+ }
246
+ }
247
+ </script> <div class="sign__desc">
248
 
249
+ <p>Already have an account? <a href="/login">Sign In</a></p>
250
  </div>
251
  </div>
252
  </div>