4.6 KiB
id, title, challengeType, dashedName
id | title | challengeType | dashedName |
---|---|---|---|
60fad1cafcde010995e15306 | Step 36 | 0 | step-36 |
--description--
With form submissions, it is useful, and good practice, to provide each submittable element with a name
attribute. This attribute is used to identify the element in the form submission.
Go ahead, and give each submittable element a unique name
attribute of your choosing. Except for the two radio
inputs.
--hints--
You should give the input
expecting a first name a name
attribtute. PS I would have chosen first-name
assert.isNotEmpty(document.querySelector('fieldset:nth-child(1) > label:nth-child(1) > input')?.name);
You should give the input
expecting a last name a name
attribute. PS I would have chosen last-name
assert.isNotEmpty(document.querySelector('fieldset:nth-child(1) > label:nth-child(2) > input')?.name);
You should give the email
a name
attribute. PS I would have chosen email
assert.isNotEmpty(document.querySelector('input[type="email"]')?.name);
You should give the password
a name
attribute. PS I would have chosen password
assert.isNotEmpty(document.querySelector('input[type="password"]')?.name);
You should give the checkbox
a name
attribute. PS I would have chosen terms
assert.isNotEmpty(document.querySelector('input[type="checkbox"]')?.name);
You should give the file
a name
attribute. PS I would have chosen file
assert.isNotEmpty(document.querySelector('input[type="file"]')?.name);
You should give the number
a name
attribute. PS I would have chosen age
assert.isNotEmpty(document.querySelector('input[type="number"]')?.name);
You should give the select
element a name
attribute. PS I would have chosen referrer
assert.isNotEmpty(document.querySelector('select')?.name);
You should give the textarea
element a name
attribute. PS I would have chosen bio
assert.isNotEmpty(document.querySelector('textarea')?.name);
You should not give any of the option
elements a name
attribute.
[...document.querySelectorAll('option')]?.forEach(option => assert.isUndefined(option?.name));
You should not give any of the label
elements a name
attribute.
[...document.querySelectorAll('label')]?.forEach(label => assert.isUndefined(label?.name));
You should not give any of the fieldset
elements a name
attribute.
[...document.querySelectorAll('fieldset')]?.forEach(fieldset => assert.isEmpty(fieldset?.name));
--seed--
--seed-contents--
<!DOCTYPE html>
<html>
<head>
<title>Registration Form</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
<h1>Registration Form</h1>
<p>Please fill out this form with the required information</p>
<form action='https://fcc-registration-form.com'>
--fcc-editable-region--
<fieldset>
<label>Enter Your First Name: <input type="text" required /></label>
<label>Enter Your Last Name: <input type="text" required /></label>
<label>Enter Your Email: <input type="email" required /></label>
<label>Create a New Password: <input type="password" pattern="[a-z0-5]{8,}" required /></label>
</fieldset>
<fieldset>
<label><input type="radio" name="account-type" /> Personal Account</label>
<label><input type="radio" name="account-type" /> Business Account</label>
<label>
<input type="checkbox" required /> I accept the <a href="https://www.freecodecamp.org/news/terms-of-service/">terms and conditions</a>
</label>
</fieldset>
<fieldset>
<label>Upload a profile picture: <input type="file" /></label>
<label>Input your age (years): <input type="number" min="13" max="120" />
</label>
<label>How did you hear about us?
<select>
<option value="">(select one)</option>
<option value="1">freeCodeCamp News</option>
<option value="2">freeCodeCamp YouTube Channel</option>
<option value="3">freeCodeCamp Forum</option>
<option value="4">Other</option>
</select>
</label>
<label>Provide a bio:
<textarea rows="3" cols="30" placeholder="I like coding on the beach..."></textarea>
</label>
</fieldset>
--fcc-editable-region--
<input type="submit" value="Submit" />
</form>
</body>
</html>
body {
width: 100%;
height: 100vh;
margin: 0;
background-color: #1b1b32;
color: #f5f6f7;
}
label {
display: block;
margin: 0.5rem 0;
}