mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2025-06-28 04:45:36 -04:00
feat: added file upload + dir creation
This commit is contained in:
parent
b1c295d2ac
commit
eedab606f8
25 changed files with 965 additions and 103 deletions
|
@ -1,14 +1,57 @@
|
|||
console.log('form stuff');
|
||||
|
||||
const usernameCheck = async (username) => {
|
||||
let res = await fetch(`/auth/username?username=${username}`);
|
||||
return await res.json();
|
||||
if (username.length > 0) {
|
||||
let res = await fetch(`/auth/username?username=${username}`);
|
||||
const data = await res.json();
|
||||
// return true if username is available
|
||||
return data.results === false;
|
||||
}
|
||||
};
|
||||
|
||||
const input = document.querySelector("input[name='username']");
|
||||
const emailCheck = async (email) => {
|
||||
if (email.length > 0) {
|
||||
let res = await fetch(`/auth/email?email=${email}`);
|
||||
const data = await res.json();
|
||||
return data.results === false;
|
||||
}
|
||||
};
|
||||
|
||||
input.addEventListener('input', async (e) => {
|
||||
let input = e.target.value;
|
||||
let test = await usernameCheck(input);
|
||||
test.results ? console.log('user exists') : console.log('user doesnt');
|
||||
});
|
||||
const isDataValid = async (e, callback) => {
|
||||
let test = await callback(e.target.value);
|
||||
test
|
||||
? (e.target.style.border = '3px green solid')
|
||||
: (e.target.style.border = 'red solid 3px');
|
||||
};
|
||||
|
||||
const passwordValid = () => {
|
||||
const password = document.querySelector('#password');
|
||||
const passwordConfirmation = document.querySelector(
|
||||
'#password-confirmation',
|
||||
);
|
||||
|
||||
const passwordConfirmationCheck = (value) => {
|
||||
return password.value === value;
|
||||
};
|
||||
|
||||
const passwordValidityCheck = (password) => {
|
||||
if (!/\d/.test(password)) return false;
|
||||
if (!/[\!@#%\^&\*\(\)\_\+\-=\[\]{}\|;':",\.\/\<\>\~\`]/.test(password))
|
||||
return false;
|
||||
if (password.length < 8) return false;
|
||||
|
||||
return true;
|
||||
};
|
||||
password.addEventListener('input', (e) =>
|
||||
isDataValid(e, passwordValidityCheck),
|
||||
);
|
||||
passwordConfirmation.addEventListener('input', (e) =>
|
||||
isDataValid(e, passwordConfirmationCheck),
|
||||
);
|
||||
};
|
||||
|
||||
const usernameInput = document.querySelector("input[name='username']");
|
||||
usernameInput.addEventListener('input', (e) => isDataValid(e, usernameCheck));
|
||||
|
||||
const emailInput = document.querySelector("input[name='email']");
|
||||
emailInput.addEventListener('input', (e) => isDataValid(e, emailCheck));
|
||||
|
||||
passwordValid();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue