What is the purpose of form validation styles in Bootstrap?
Form validation styles in Bootstrap help visually indicate to users whether their input is valid or invalid, improving user experience and accessibility.
Click to reveal answer
beginner
Which Bootstrap class adds a green border and check icon to a valid input field?
The class is-valid adds a green border and a check icon to indicate the input is valid.
Click to reveal answer
beginner
Which Bootstrap class adds a red border and cross icon to an invalid input field?
The class is-invalid adds a red border and a cross icon to indicate the input is invalid.
Click to reveal answer
beginner
How do you display a custom error message below an invalid input in Bootstrap?
Use a <div> with the class invalid-feedback immediately after the input field to show a custom error message.
Click to reveal answer
intermediate
What attribute should be added to a form to enable Bootstrap's custom validation styles?
Add the novalidate attribute to the <form> element to disable native browser validation and use Bootstrap's custom styles.
Click to reveal answer
Which class would you add to an input to show it is valid in Bootstrap?
Ais-valid
Bis-invalid
Cvalid-input
Dinput-valid
✗ Incorrect
The is-valid class applies green border and check icon to valid inputs.
What class shows a red border and error icon for invalid inputs?
Ainvalid-feedback
Binput-error
Cis-invalid
Derror-input
✗ Incorrect
The is-invalid class styles inputs with a red border and error icon.
Where should you place the invalid-feedback element?
AImmediately after the input field
BInside the input field
CBefore the input field
DAnywhere in the form
✗ Incorrect
The invalid-feedback element must be placed immediately after the input to show error messages properly.
What does the novalidate attribute do on a form?
AEnables native browser validation
BAdds Bootstrap validation styles automatically
CPrevents form submission
DDisables native browser validation
✗ Incorrect
The novalidate attribute disables native browser validation so you can use custom Bootstrap validation.
Which icon appears with is-valid class in Bootstrap forms?
ARed cross
BGreen checkmark
CYellow warning
DBlue info
✗ Incorrect
The is-valid class shows a green checkmark icon to indicate valid input.
Explain how to use Bootstrap classes to show valid and invalid form input states.
Think about the colors and icons that help users know if their input is correct.
You got /4 concepts.
Describe how to add custom error messages for invalid inputs using Bootstrap.
Where do you put the message and what class do you use?
You got /4 concepts.
Practice
(1/5)
1. Which Bootstrap class should you add to an input element to show it has valid data?
easy
A. valid-feedback
B. is-invalid
C. is-valid
D. invalid-feedback
Solution
Step 1: Understand Bootstrap validation classes
Bootstrap uses is-valid to mark inputs as valid and is-invalid for invalid inputs.
Step 2: Identify the class for valid input
The class is-valid visually marks the input as valid with green borders and icons.
Final Answer:
is-valid -> Option C
Quick Check:
Valid input class = is-valid [OK]
Hint: Valid input uses is-valid class for green highlight [OK]
Common Mistakes:
Confusing is-valid with is-invalid
Using feedback classes on input instead of messages
Not adding any validation class
2. Which of the following is the correct way to add invalid feedback text below an input in Bootstrap?
easy
A.
Error message
B.
Error message
C. Error message
D.
Error message
Solution
Step 1: Identify the correct feedback container
Bootstrap uses invalid-feedback class inside a div to show invalid messages.
Step 2: Match the correct HTML structure
The correct syntax is <div class="invalid-feedback">Message</div> placed after the input.
Final Answer:
<div class="invalid-feedback">Error message</div> -> Option B
Quick Check:
Invalid feedback uses div.invalid-feedback [OK]
Hint: Use div with invalid-feedback class for error messages [OK]
Common Mistakes:
Using is-invalid class on feedback text instead of input
Using valid-feedback class for invalid messages
Placing feedback inside input tag
3. What will be the visual result of this code snippet?
<input type="text" class="form-control is-invalid" />
<div class="invalid-feedback">Please enter a valid name.</div>
medium
A. Input box with red border and error message below
B. Input box with green border and success message below
C. Input box with no border color change and no message
D. Input box with blue border and warning message below
Solution
Step 1: Analyze the input classes
The input has is-invalid which applies a red border and error icon.
Step 2: Check the feedback message
The invalid-feedback div shows the error message below the input in red text.
Final Answer:
Input box with red border and error message below -> Option A
Quick Check:
is-invalid + invalid-feedback = red error style [OK]
5. You want to create a form where the input shows green border and a success message only after the user submits valid data. Which Bootstrap classes and structure should you use?
hard
A. Add is-valid to input and place success message inside div.valid-feedback after input
B. Add is-invalid to input and place success message inside div.invalid-feedback
C. Add valid-feedback class to input and place message inside span
D. Add is-valid to input and place success message inside span.invalid-feedback
Solution
Step 1: Choose correct validation class for success
Use is-valid on input to show green border and success icon.
Step 2: Place success message correctly
Success message goes inside a div with class valid-feedback placed immediately after the input.
Final Answer:
Add is-valid to input and place success message inside div.valid-feedback after input -> Option A
Quick Check:
Success = is-valid + div.valid-feedback [OK]
Hint: Use is-valid on input and div.valid-feedback for success message [OK]
Common Mistakes:
Mixing invalid classes with success messages
Using span instead of div for feedback
Placing feedback before input
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.