31 lines
755 B
JavaScript
31 lines
755 B
JavaScript
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 (/^[a-z0-9]+$/.test(data['username']) === false) {
|
|
alert('Username can only contain lowercase letters and numbers')
|
|
return
|
|
}
|
|
|
|
if (data['password'] != document.getElementsByName('confirmpassword')[0].value) {
|
|
alert('Passwords don\'t match')
|
|
return
|
|
}
|
|
|
|
console.log(data)
|
|
|
|
fetch(url, {
|
|
method: 'POST',
|
|
body: JSON.stringify(data),
|
|
}).then((response) => {
|
|
alert(response.statusText)
|
|
})
|
|
})
|