-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
34 lines (30 loc) · 918 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
31
32
33
34
function showAlert()
{
return alert('goodbye.');
}
const badbutton = document.getElementById("badbutton");
const gudbutton = document.getElementById("goodbutton");
badbutton.addEventListener("click", function(){
alert("told ya to not click me mf.");
});
gudbutton.addEventListener("click", function(){
alert("thank you~");
});
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.');
}
}