-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
30 lines (24 loc) · 832 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
document.querySelector("button.button-menu-toggle").addEventListener("click", function() {
document.querySelector(".nav-links").classList.toggle("nav-links-responsive")
})
function showAlert() {
alert("¡Hola, esta es una alerta de JavaScript!");
}
const form = document.getElementById('myForm');
form.addEventListener('submit', function(event) {
event.preventDefault();
validateForm();
});
function validateEmail(email) {
const regex = /^[^\s@]+@[^\s@]+\.[^\s@]{2,7}$/
return regex.test(email)
}
function validateForm() {
const emailInput = document.getElementById('email');
const email = emailInput.value;
if (!validateEmail(email)) {
alert('Por favor ingrese un correo electrónico válido.');
} else {
alert('Correo electrónico enviado correctamente.');
}
}