sermon-notes/public/theme/assets/js/login.js

23 lines
759 B
JavaScript
Raw Normal View History

2024-05-13 21:09:41 -04:00
// script.js
const form = document.querySelector('form');
const usernameInput = document.querySelector('#username');
const passwordInput = document.querySelector('#password');
function handleFormSubmit(event) {
event.preventDefault();
const username = usernameInput.value;
const password = passwordInput.value;
if (username === '' || password === '') {
alert('Please enter a valid username and password.');
return false;
}
// Send an AJAX request to the server with the form data
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://example.com/login', true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.send(`username=${username}&password=${password}`);
}