2021-02-06 04:42:36 +00:00
---
id: bad87fee1348bd9aede08830
title: Crea un elemento de formulario
challengeType: 0
forumTopicId: 16817
dashedName: create-a-form-element
---
# --description--
Puedes construir formularios web que realmente envíen datos a un servidor usando sólo HTML puro. Puedes hacer esto especificando un atributo `action` en tu elemento `form` .
Por ejemplo:
```html
2022-02-23 18:40:00 +05:30
< form action = "url-where-you-want-to-submit-form-data" >
2021-02-06 04:42:36 +00:00
< input >
< / form >
```
# --instructions--
2021-04-28 22:13:20 +09:00
Anida el elemento `input` existente dentro de un elemento `form` y asigna `"https://www.freecatphotoapp.com/submit-cat-photo"` al atributo `action` del elemento `form` .
2021-02-06 04:42:36 +00:00
# --hints--
El elemento `input` existente debe anidarse dentro de un elemento `form` .
```js
const inputElem = document.querySelector('form input');
assert(
inputElem.getAttribute('type') === 'text' & &
inputElem.getAttribute('placeholder') === 'cat photo URL'
);
```
2021-06-20 22:29:09 +05:30
Tu formulario `form` debe tener un atributo `action` que esté establecido como `https://www.freecatphotoapp.com/submit-cat-photo` .
2021-02-06 04:42:36 +00:00
```js
2021-05-06 17:11:14 +02:00
const action = $('form').attr('action');
assert(action.match(/^https:\/\/(www\.)?freecatphotoapp\.com\/submit-cat-photo$/i))
2021-02-06 04:42:36 +00:00
```
Tu elemento `form` debe tener etiquetas correctamente abiertas y cerradas.
```js
assert(
code.match(/< \/form > /g) &&
code.match(/< form [ ^ < ] * > /g) & &
code.match(/< \/form > /g).length === code.match(/< form [^<]* > /g).length
);
```
# --seed--
## --seed-contents--
```html
< h2 > CatPhotoApp< / h2 >
< main >
< p > Click here to view more < a href = "#" > cat photos< / a > .< / p >
2021-09-22 08:34:59 -07:00
< a href = "#" > < img src = "https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt = "A cute orange cat lying on its back." > < / a >
2021-02-06 04:42:36 +00:00
< p > Things cats love:< / p >
< ul >
< li > cat nip< / li >
< li > laser pointers< / li >
< li > lasagna< / li >
< / ul >
< p > Top 3 things cats hate:< / p >
< ol >
< li > flea treatment< / li >
< li > thunder< / li >
< li > other cats< / li >
< / ol >
< input type = "text" placeholder = "cat photo URL" >
< / main >
```
# --solutions--
```html
< h2 > CatPhotoApp< / h2 >
< main >
< p > Click here to view more < a href = "#" > cat photos< / a > .< / p >
2021-09-22 08:34:59 -07:00
< a href = "#" > < img src = "https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt = "A cute orange cat lying on its back." > < / a >
2021-02-06 04:42:36 +00:00
< p > Things cats love:< / p >
< ul >
< li > cat nip< / li >
< li > laser pointers< / li >
< li > lasagna< / li >
< / ul >
< p > Top 3 things cats hate:< / p >
< ol >
< li > flea treatment< / li >
< li > thunder< / li >
< li > other cats< / li >
< / ol >
2021-04-28 22:13:20 +09:00
< form action = "https://www.freecatphotoapp.com/submit-cat-photo" >
2021-02-06 04:42:36 +00:00
< input type = "text" placeholder = "cat photo URL" >
< / form >
< / main >
```