--- id: 60fabf0dd4959805dbae09e6 title: 步驟 28 challengeType: 0 dashedName: step-28 --- # --description-- 在第一個 `label` 在添加另一個,其文本爲 `Input your age (years):`。 在它後面添加一個 `input` 並設置其 `type` 爲 `number`。 由於我們不希望 13 歲以下的用戶註冊,給 `input` 添加一個 `min` 屬性並設置其值爲 `13`。 此外,我們假設年齡超過 120 歲的用戶不會來註冊,添加一個 `max` 屬性,並設置其值爲 `120`。 現在,如果提交的表單裏面的年齡超過了這個範圍,會出現一個警告,並阻止提交。 試一下吧。 # --hints-- 應該在第三個 `fieldset` 內已存在的 `label` 後面在添加一個 `label`。 ```js assert.exists(document.querySelector('fieldset:nth-child(3) > label + label')); ``` `label` 的文字應該爲 `Input your age (years):`。 ```js assert.equal(document.querySelector('fieldset:nth-child(3) > label:nth-child(2)')?.textContent?.trim(), 'Input your age (years):'); ``` `label` 內應該有一個 `type` 爲 `number` 的 `input`。 ```js assert.exists(document.querySelector('fieldset:nth-child(3) > label:nth-child(2) > input[type="number"]')); ``` `input` 應該有一個 `min` 屬性且其值爲 `13`。 ```js assert.equal(document.querySelector('fieldset:nth-child(3) > label:nth-child(2) > input[type="number"]')?.min, '13'); ``` `input` 應該有一個 `max` 屬性且其值爲 `120`。 ```js assert.equal(document.querySelector('fieldset:nth-child(3) > label:nth-child(2) > input[type="number"]')?.max, '120'); ``` # --seed-- ## --seed-contents-- ```html Registration Form

Registration Form

Please fill out this form with the required information

--fcc-editable-region--
--fcc-editable-region--
``` ```css body { width: 100%; height: 100vh; margin: 0; background-color: #1b1b32; color: #f5f6f7; } label { display: block; margin: 0.5rem 0; } ```