forked from .cyb/cyberman
20 lines
626 B
JavaScript
20 lines
626 B
JavaScript
function checkAvailability() {
|
|
let name = document.getElementById('name').value;
|
|
if (name === '') {
|
|
document.getElementById('avail').innerHTML = '';
|
|
return;
|
|
}
|
|
document.getElementById('avail').innerHTML = 'Checking availability...';
|
|
fetch('/api/check_availability?name=' + encodeURIComponent(name), {
|
|
method: 'GET',
|
|
mode: 'cors'
|
|
}).then(g => g.text()).then(g => {
|
|
if (g === 'y') {
|
|
document.getElementById('avail').innerHTML = 'Available!';
|
|
} else {
|
|
document.getElementById('avail').innerHTML = 'Not available';
|
|
}
|
|
}).catch((e) => {
|
|
document.getElementById('avail').innerHTML = 'Server error';
|
|
});
|
|
} |