Rework how form data is collected for signup
This commit is contained in:
parent
174655a07c
commit
9ce0d02be7
3 changed files with 14 additions and 35 deletions
|
@ -14,6 +14,11 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||
submitSignup();
|
||||
});
|
||||
|
||||
const usernameInput = document.getElementById("signup_username");
|
||||
usernameInput.addEventListener("blur", function () {
|
||||
checkUsernameAvailability();
|
||||
});
|
||||
|
||||
|
||||
loginForm.addEventListener("submit", function (event) {
|
||||
event.preventDefault(); // Prevent the form from being submitted normally
|
||||
|
@ -31,15 +36,9 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||
}
|
||||
});
|
||||
|
||||
const usernameInput = document.getElementById("signup-username");
|
||||
usernameInput.addEventListener("blur", function () {
|
||||
checkUsernameAvailability();
|
||||
});
|
||||
|
||||
|
||||
|
||||
function checkUsernameAvailability() {
|
||||
const usernameInput = document.getElementById("signup-username");
|
||||
const usernameInput = document.getElementById("signup_username");
|
||||
const availabilityDiv = document.getElementById("usernameAvailability");
|
||||
|
||||
// Get the value of the username input
|
||||
|
@ -78,18 +77,18 @@ function submitSignup() {
|
|||
submitBtn.innerHTML = '';
|
||||
submitBtn.appendChild(spinner);
|
||||
|
||||
// Get the values of the signup form fields
|
||||
// Get the values of the form fields
|
||||
const signup_username = document.getElementById("signup_username").value;
|
||||
const signup_password = document.getElementById("signup_password").value;
|
||||
const name = document.getElementById("name").value;
|
||||
const email = document.getElementById("email").value;
|
||||
const username = document.getElementById("signup-username").value;
|
||||
const password = document.getElementById("signup-password").value;
|
||||
|
||||
// Create a new FormData object and append the values
|
||||
const formData = new FormData();
|
||||
formData.append("name", name);
|
||||
formData.append("email", email);
|
||||
formData.append("username", username);
|
||||
formData.append("password", password);
|
||||
formData.append("username", signup_username);
|
||||
formData.append("password", signup_password);
|
||||
|
||||
// Send the signup request as form data
|
||||
const xhr = new XMLHttpRequest();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue