const url = 'https://exozy.me/new/'
const form = document.querySelector('form')
form.addEventListener('submit', (e) => {
e.preventDefault()
const data = new Object()
for (const s of ['code', 'firstname', 'lastname', 'email', 'username', 'password']) {
data[s] = document.getElementsByName(s)[0].value
if (data[s] == '') {
alert('Please fill out the form completely')
return
}
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')
if (data['password'] != document.getElementsByName('confirmpassword')[0].value) {
alert('Passwords don\'t match')
console.log(data)
fetch(url, {
method: 'POST',
body: JSON.stringify(data),
}).then((response) => {
alert(response.statusText)
})