| 1 | <!DOCTYPE html> |
| 2 | <html lang="es" class="light dark"> |
| 3 | |
| 4 | <head> |
| 5 | |
| 6 | <meta charset="UTF-8"> |
| 7 | |
| 8 | <title>Agregar - PWA con Crud</title> |
| 9 | |
| 10 | <meta name="description" content="Ejemplo de PWA con Formulario"> |
| 11 | |
| 12 | <script type="module" src="js/lib/registraServiceWorker.js"></script> |
| 13 | <script type="module" src="js/lib/manejaErrores.js"></script> |
| 14 | |
| 15 | <meta name="viewport" content="width=device-width"> |
| 16 | <meta name="theme-color" content="#fffbfe"> |
| 17 | <link rel="icon" sizes="32x32" href="favicon.ico"> |
| 18 | <link rel="manifest" href="site.webmanifest"> |
| 19 | <script src="ungap/custom-elements.js"></script> |
| 20 | |
| 21 | <script type="module" src="js/lib/custom/md-app-bar.js"></script> |
| 22 | |
| 23 | <link rel="stylesheet" href="css/estilos.css"> |
| 24 | <link rel="stylesheet" href="css/transicion_pestanas.css"> |
| 25 | <link rel="stylesheet" href="css/md-filled-text-field.css"> |
| 26 | <link rel="stylesheet" href="css/material-symbols-outlined.css"> |
| 27 | <link rel="stylesheet" href="css/md-standard-icon-button.css"> |
| 28 | |
| 29 | </head> |
| 30 | |
| 31 | <body> |
| 32 | |
| 33 | <form id="formulario" novalidate> |
| 34 | |
| 35 | <md-app-bar adicional="tab"> |
| 36 | |
| 37 | <a class="md-standard-icon-button" slot="navigation" title="Cancelar" |
| 38 | href="index.html"> |
| 39 | <span class="material-symbols-outlined">cancel</span></a> |
| 40 | |
| 41 | <h1>Agregar</h1> |
| 42 | |
| 43 | <button type="submit" class="md-standard-icon-button" title="Guardar" |
| 44 | slot="action"> |
| 45 | <span class="material-symbols-outlined">save</span> |
| 46 | </button> |
| 47 | |
| 48 | </md-app-bar> |
| 49 | |
| 50 | <section> |
| 51 | |
| 52 | <p> |
| 53 | <label class="md-filled-text-field"> |
| 54 | <input name="nombre" required placeholder="Nombre*"> |
| 55 | <span>Nombre *</span> |
| 56 | <small id="supportingNombre">Obligatorio</small> |
| 57 | </label> |
| 58 | </p> |
| 59 | |
| 60 | </section> |
| 61 | |
| 62 | </form> |
| 63 | |
| 64 | <script type="module"> |
| 65 | |
| 66 | import { muestraTextoDeAyuda } from "./js/lib/muestraTextoDeAyuda.js" |
| 67 | |
| 68 | formulario.nombre.addEventListener("input", copiaMensajes) |
| 69 | formulario.addEventListener("submit", guardar) |
| 70 | |
| 71 | function copiaMensajes() { |
| 72 | muestraTextoDeAyuda(formulario.nombre, supportingNombre, "Obligatorio") |
| 73 | } |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | function guardar(evt) { |
| 79 | evt.preventDefault() |
| 80 | copiaMensajes() |
| 81 | if (formulario.nombre.validity.valid) { |
| 82 | location.href = "index.html" |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | </script> |
| 87 | |
| 88 | </body> |
| 89 | |
| 90 | </html> |