mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-06-22 21:08:12 +08:00
fix(curriculum): add an example for the "required" attribute (#58993)
This commit is contained in:
parent
48df556ed7
commit
ab3cbbe980
@ -7,7 +7,15 @@ dashedName: step-43
|
||||
|
||||
# --description--
|
||||
|
||||
To prevent a user from submitting your form when required information is missing, you need to add the `required` attribute to an `input` element. There's no need to set a value to the `required` attribute. Instead, just add the word `required` to the `input` element, making sure there is space between it and other attributes.
|
||||
To prevent a user from submitting your form when required information is missing, you need to add the `required` attribute to an `input` element.
|
||||
|
||||
Here is an example of an input field with the `required` attribute:
|
||||
|
||||
```html
|
||||
<input type="text" name="firstName" required>
|
||||
```
|
||||
|
||||
There's no need to set a value to the `required` attribute. Instead, just add the word `required` to the `input` element, making sure there is space between it and other attributes.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user