1 | <!DOCTYPE html> |
2 | <html lang="es"> |
3 | |
4 | <head> |
5 | |
6 | <meta charset="UTF-8"> |
7 | <meta name="viewport" content="width=device-width"> |
8 | |
9 | <title>Servicio que valida datos</title> |
10 | |
11 | </head> |
12 | |
13 | <body> |
14 | |
15 | <h1>Servicio que valida datos</h1> |
16 | |
17 | <form onsubmit="procesaForma(event) "> |
18 | |
19 | <p> |
20 | <label> |
21 | Saludo: |
22 | |
23 | |
24 | <input name="saludo"> |
25 | </label> |
26 | </p> |
27 | |
28 | <p> |
29 | <label> |
30 | Nombre: |
31 | |
32 | |
33 | <input name="nombre"> |
34 | </label> |
35 | </p> |
36 | |
37 | <p><button type="submit">Procesa</button></p> |
38 | |
39 | </form> |
40 | |
41 | <script type="module"> |
42 | |
43 | import { exportaAHtml } from "./lib/js/exportaAHtml.js" |
44 | import { muestraError } from "./lib/js/muestraError.js" |
45 | import { submitForm } from "./lib/js/submitForm.js" |
46 | |
47 | |
48 | |
49 | |
50 | async function procesaForma(event) { |
51 | try { |
52 | const respuesta = |
53 | await submitForm( |
54 | "srv/valida.php", event) |
55 | alert(respuesta.body) |
56 | } catch (error) { |
57 | muestraError(error) |
58 | } |
59 | } |
60 | exportaAHtml(procesaForma) |
61 | |
62 | </script> |
63 | |
64 | </body> |
65 | |
66 | </html> |