3.5 KiB
id | title | challengeType | dashedName |
---|---|---|---|
5ef9b03c81a63668521804d7 | Step 36 | 0 | step-36 |
--description--
L'attributo action
indica dove dovrebbero essere inviati i dati del modulo. Ad esempio, <form action="/submit-url"></form>
indica al browser che i dati del modulo dovrebbero essere inviati al percorso /submit-url
.
Aggiungi all'elemento form
un attributo action
con il valore https://freecatphotoapp.com/submit-cat-photo
.
--hints--
L'elemento form
dovrebbe avere un tag di apertura e un tag di chiusura nell'ordine corretto. Potrebbero mancare uno o entrambi i tag richiesti, o essere nell'ordine sbagliato.
const noSpaces = code.replace(/\s/g, '');
assert(
document.querySelector('form') &&
code.match(/<\/form>/g) &&
noSpaces.indexOf('<form') < noSpaces.indexOf('</form>')
);
L'elemento form
annidato nell'ultimo elemento section
dovrebbe essere al di sotto dell'elemento h2
. L'elemento h2
e l'elemento form
sono nell'ordine sbagliato.
assert(document.querySelector('form').previousElementSibling.nodeName === 'H2');
L'elemento form
non dovrebbe avere contenuti. Rimuovi qualsiasi elemento HTML o testo tra i tag dell'elemento form
.
assert($('form')[0].innerHTML.trim().length === 0);
L'elemento form
non ha un attributo action
. Controlla che ci sia uno spazio dopo il nome del tag di apertura e/o che ci siano spazi prima di tutti i nomi degli attributi.
const form = document.querySelector('form');
assert(form.hasAttribute('action'));
L'elemento del modulo form
dovrebbe avere un attributo action
con il valore https://freecatphotoapp.com/submit-cat-photo
.
const form = document.querySelector('form');
assert(
form
.getAttribute('action')
.match(/^https:\/\/freecatphotoapp\.com\/submit-cat-photo$/)
);
Anche se l'URL dell'attributo action
è corretto, è sempre raccomandato inserire il valore di un attributo tra virgolette.
assert(
!/\<form\s+action\s*=\s*https:\/\/freecatphotoapp\.com\/submit-cat-photo/.test(
code
)
);
--seed--
--seed-contents--
<html>
<body>
<h1>CatPhotoApp</h1>
<main>
<section>
<h2>Cat Photos</h2>
<!-- TODO: Add link to cat photos -->
<p>Click here to view more <a target="_blank" href="https://freecatphotoapp.com">cat photos</a>.</p>
<a href="https://freecatphotoapp.com"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
</section>
<section>
<h2>Cat Lists</h2>
<h3>Things cats love:</h3>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<figure>
<img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/lasagna.jpg" alt="A slice of lasagna on a plate.">
<figcaption>Cats <em>love</em> lasagna.</figcaption>
</figure>
<h3>Top 3 things cats hate:</h3>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
<figure>
<img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/cats.jpg" alt="Five cats looking around a field.">
<figcaption>Cats <strong>hate</strong> other cats.</figcaption>
</figure>
</section>
<section>
<h2>Cat Form</h2>
--fcc-editable-region--
<form>
</form>
--fcc-editable-region--
</section>
</main>
</body>
</html>