This repository has been archived on 2024-01-05. You can view files and clone it, but cannot push or open issues or pull requests.
website/register/register.js

36 lines
943 B
JavaScript
Raw Normal View History

2021-11-22 20:48:46 +00:00
const url = 'https://exozy.me/new/'
const form = document.querySelector('form')
form.addEventListener('submit', (e) => {
e.preventDefault()
const data = new Object()
2021-11-23 18:44:04 +00:00
for (const s of ['code', 'firstname', 'lastname', 'email', 'username', 'password']) {
2021-11-22 20:48:46 +00:00
data[s] = document.getElementsByName(s)[0].value
if (data[s] == '') {
alert('Please fill out the form completely')
return
}
2021-11-22 20:48:46 +00:00
}
if (/^[a-z0-9]+$/.test(data['username']) === false || (data['username'][0] >= '0' && data['username'][0] <= '9')) {
alert('Username can only contain lowercase letters and numbers and can\'t start with a number')
2021-11-24 16:14:24 +00:00
return
}
if (data['password'] != document.getElementsByName('confirmpassword')[0].value) {
alert('Passwords don\'t match')
2021-11-23 02:38:04 +00:00
return
}
2021-11-22 20:48:46 +00:00
console.log(data)
fetch(url, {
method: 'POST',
body: JSON.stringify(data),
}).then((response) => {
alert(response.statusText)
})
2021-11-23 02:38:04 +00:00
})