2021-06-14 18:34:20 +00:00
---
id: bad87fee1348bd9aede08830
title: Criar um elemento de formulário
challengeType: 0
forumTopicId: 16817
dashedName: create-a-form-element
---
# --description--
Você pode criar formulários que enviam dados a um servidor usando apenas HTML puro. Você pode fazer isso especificando o atributo `action` ao elemento `form` .
Por exemplo:
```html
< form action = "/url-where-you-want-to-submit-form-data" >
< input >
< / form >
```
# --instructions--
Coloque o elemento `input` que já existe dentro de um elemento `form` e insira `"https://www.freecatphotoapp.com/submit-cat-photo"` no atributo `action` do elemento `form` .
# --hints--
O elemento `input` existente deve ficar dentro do elemento `form` .
```js
const inputElem = document.querySelector('form input');
assert(
inputElem.getAttribute('type') === 'text' & &
inputElem.getAttribute('placeholder') === 'cat photo URL'
);
```
2021-06-20 16:59:09 +00:00
O elemento `form` deve ter o atributo `action` definido como `https://www.freecatphotoapp.com/submit-cat-photo` .
2021-06-14 18:34:20 +00:00
```js
const action = $('form').attr('action');
assert(action.match(/^https:\/\/(www\.)?freecatphotoapp\.com\/submit-cat-photo$/i))
```
O elemento `form` deve ter as tags de abertura e fechamento corretas.
```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 >
< a href = "#" > < img src = "https://www.bit.ly/fcc-relaxing-cat" alt = "A cute orange cat lying on its back." > < / a >
< 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 >
< a href = "#" > < img src = "https://www.bit.ly/fcc-relaxing-cat" alt = "A cute orange cat lying on its back." > < / a >
< 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 >
< form action = "https://www.freecatphotoapp.com/submit-cat-photo" >
< input type = "text" placeholder = "cat photo URL" >
< / form >
< / main >
```