diff --git a/estilo.css b/estilo.css index 040e932..ef1bcf0 100644 --- a/estilo.css +++ b/estilo.css @@ -90,7 +90,14 @@ tr:hover { color: red; font-size: 0.75em; } +.visible{ +display :block +} +.invisible{ +display: none + +} #boton-agregar:hover { background-color: #0ca37a; } diff --git a/index.html b/index.html index c975a59..45f1c53 100644 --- a/index.html +++ b/index.html @@ -28,7 +28,7 @@ -
+Error
diff --git a/script.js b/script.js index e6026aa..f9c5cd0 100644 --- a/script.js +++ b/script.js @@ -21,7 +21,19 @@ function mostrarTabla(libros) { } } mostrarTabla(libros); - }) -// Invocamos la función al inicio para poblar la tabla con los datos del array +const boton = document.querySelector("#boton-agregar"); +const error = document.querySelector("#error") +boton.addEventListener("click", function(){ +const titulo = document.querySelector("#titulo").value; +const autor = document.querySelector("#autor").value; +const anio = document.querySelector("#anio").value; +const calificacion = document.querySelector("#calificacion").value; +if (titulo === "" || autor === "" || anio === "" || calificacion < 0 || calificacion > 10) { + error.classList.add("visible"); + error.classList.remove("invisible"); +} +}) + +