2021-06-15 03:34:20 +09:00
---
id: bad87fee1348bd9aede08830
title: Creare un modulo
challengeType: 0
forumTopicId: 16817
dashedName: create-a-form-element
---
# --description--
Puoi creare dei moduli web (form) che inviino effettivamente dei dati a un server utilizzando nient'altro che puro HTML. Puoi farlo specificando un attributo `action` nel tuo elemento `form` .
Ad esempio:
```html
2022-02-23 18:40:00 +05:30
< form action = "url-where-you-want-to-submit-form-data" >
2021-06-15 03:34:20 +09:00
< input >
< / form >
```
# --instructions--
Nidifica l'elemento `input` esistente all'interno di un elemento `form` e assegna `"https://www.freecatphotoapp.com/submit-cat-photo"` all'attributo `action` dell'elemento `form` .
# --hints--
L'elemento `input` esistente dovrebbe essere annidato in un elemento `form` .
```js
const inputElem = document.querySelector('form input');
assert(
inputElem.getAttribute('type') === 'text' & &
inputElem.getAttribute('placeholder') === 'cat photo URL'
);
```
2021-06-17 23:49:01 +09:00
Il tuo `form` dovrebbe avere un attributo `action` impostato su `https://www.freecatphotoapp.com/submit-cat-photo` .
2021-06-15 03:34:20 +09:00
```js
const action = $('form').attr('action');
assert(action.match(/^https:\/\/(www\.)?freecatphotoapp\.com\/submit-cat-photo$/i))
```
Il tuo elemento `form` dovrebbe avere tag di apertura e di chiusura ben formati.
```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-06-15 03:34:20 +09: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-06-15 03:34:20 +09: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 >
< form action = "https://www.freecatphotoapp.com/submit-cat-photo" >
< input type = "text" placeholder = "cat photo URL" >
< / form >
< / main >
```