curriculum/challenges/english/blocks/quiz-form-validation-with-javascript/66edd3403d7077eece6dc4b6.md
To pass the quiz, you must correctly answer at least 18 of the 20 questions below.
Which method is used to check if an input element's value satisfies the validation rules?
validateInput()
isValid()
checkValue()
checkValidity()
What happens if the checkValidity() method finds an invalid input?
The form is automatically submitted.
Nothing happens.
The input value is cleared.
The browser displays a validation message.
Which method is used to customize the message shown during validation failure?
setErrorMessage()
setValidationMessage()
customMessage()
setCustomValidity()
What is the default validation behavior for required fields when the form is submitted?
The form is submitted even if required fields are empty.
The form submits but gives a warning.
The form resets the input values.
The browser stops the form submission if required fields are empty.
Which actions does not cause an HTML form to be checked for errors?
Changing the input value.
Submitting the form.
Calling reportValidity().
Clicking a reset button.
What does checkValidity() return when all form inputs are valid?
false
undefined
null
true
When does the checkValidity() method stop form submission?
When the form has no submit button.
When the form action is empty.
When the form method is POST.
When the form has at least one invalid input (and the default behavior of form submission is prevented).
What happens if checkValidity() is called, but a field fails validation?
The form submits without error.
The input values are cleared.
The form closes immediately.
The invalid field is highlighted and a message appears.
Which action will make checkValidity() run?
Resetting the form.
Changing an input value.
Clicking an anchor tag.
Submitting the form manually.
What is the purpose of calling checkValidity() before submitting a form?
To automatically submit the form.
To reload the page.
To clear all input fields.
To check if all input elements meet their specified constraints.
What is the main purpose of e.preventDefault()?
To reload the form.
To clear form data.
To reset the form values.
To stop the default action of an event.
When used on a form's submit event, what does e.preventDefault() do?
It submits the form.
It clears all form fields.
It disables the form temporarily.
It prevents the form from being submitted.
In which scenario is e.preventDefault() most useful?
When handling a button click that submits a form.
When closing a modal dialog.
When opening a new page.
When submitting a form and preventing a page reload.
What happens if you forget to call e.preventDefault() on a form submit event?
All the input fields are set to their default values.
The form does not submit.
The form data is lost.
The form submits and refreshes the page.
Which default behavior can be prevented using e.preventDefault()?
Editing a form.
Rendering the form.
Reloading the form.
The default behavior caused by submitting a form.
What triggers the form's submit event?
When an input field changes.
When the form is reset.
When the form's action is cleared.
When a form's submit button is clicked or Enter is pressed.
Where do you usually handle the submit event in JavaScript?
On a text input element.
On any field in the form.
On a button element outside the form.
On the form element itself.
What does the submit event do by default?
It validates the form but doesn't submit it.
It clears the form fields.
It cancels form submission.
It sends form data to the server specified in the form's action.
Which event should you listen for to handle form data when the form is submitted in JavaScript?
"input"
"change"
"focus"
"submit"
What is the default value of the method attribute in an HTML form?
"POST"
"UPDATE"
"PUT"
"GET"