feat: add a greeting button with validation
This commit is contained in:
@@ -1 +1,10 @@
|
||||
// Agregar aquí el código javascript
|
||||
|
||||
document.getElementById('greet').addEventListener('click', () => {
|
||||
const name = document.getElementById('name').value;
|
||||
if (name.trim() === '') {
|
||||
alert('Por favor, ingresa tu nombre.');
|
||||
return;
|
||||
}
|
||||
document.getElementById('greeting').textContent = `¡Hola, ${name}!`;
|
||||
});
|
||||
Reference in New Issue
Block a user