www/js/signup.js

21 lines
598 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const form = document.getElementsByTagName('form')[0]
const login = document.getElementsByName('login')[0]
const password = document.getElementsByName('password')[0]
const password2 = document.getElementsByName('password2')[0]
form.addEventListener('submit', async (e) => {
e.preventDefault()
if (!form.checkValidity()) {
return
}
if (await checkLogin(login.value)) {
alert('Пользователь с таким логином уже существует!')
}
else if (password.value != password2.value) {
alert('Пароли не совпадают!')
}
else
form.submit()
})