Back to Freecodecamp

Step 14

curriculum/challenges/english/blocks/learn-html-forms-by-building-a-registration-form/60f5d2776c854e069560fbe6.md

latest1.7 KB
Original Source

--description--

The first fieldset will hold name, email, and password fields. Start by adding four label elements to the first fieldset.

--hints--

There should be three fieldset elements in total.

js
assert.equal(document.querySelectorAll('fieldset')?.length, 3);

The fieldset elements should all be direct children of the form element.

js
assert.equal(document.querySelectorAll('form > fieldset')?.length, 3);

The four label elements should all be direct children of the first fieldset element. Make sure you close the label elements.

js
assert.equal(document.querySelectorAll('form fieldset:first-child > label')?.length, 4);

The last two fieldset elements should be empty.

js
const LastTwoFieldsetElements = Array.from(document.querySelectorAll("form fieldset:not(fieldset:first-child)"));
assert.isTrue(LastTwoFieldsetElements.filter((ele) => ele.innerHTML?.replace(/\s/g, ""))?.length === 0);

Make sure you close the label elements.

js
assert.lengthOf(document.querySelector('fieldset')?.innerHTML?.match(/<\/label>/g), 4)

--seed--

--seed-contents--

html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Registration Form</title>
    <link rel="stylesheet" href="styles.css" />
  </head>
  <body>
    <h1>Registration Form</h1>
    <p>Please fill out this form with the required information</p>
--fcc-editable-region--
    <form method="post" action='https://register-demo.freecodecamp.org'>
      <fieldset>

      </fieldset>
      <fieldset></fieldset>
      <fieldset></fieldset>
    </form>
--fcc-editable-region--
  </body>
</html>
css
body {
  width: 100%;
  height: 100vh;
  margin: 0;
  background-color: #1b1b32;
  color: #f5f6f7;
}