Loading

Quipoin Menu

Learn • Practice • Grow

react / Form Validation in React
mcq
Direction: Choose the correct option

Q1.

Where should form validation logic typically reside in React?
A. In a separate validation function called on submit or on change
B. In the render method
C. In the form's onChange handler
D. In the global scope
Direction: Choose the correct option

Q2.

How can you display validation errors to the user?
A. By modifying the DOM directly
B. Using console.log
C. By setting error messages in state and rendering them conditionally
D. Using alert()
Direction: Choose the correct option

Q3.

What is a common library for form validation in React?
A. Formik
B. Axios
C. Redux
D. React Router
Direction: Choose the correct option

Q4.

In a controlled component, when is a good time to validate?
A. On every change, on blur, or on submit depending on UX
B. Only on submit
C. Never
D. Only on mount
Direction: Choose the correct option

Q5.

What does the 'required' attribute do in a form input?
A. It makes the field mandatory in HTML5 validation
B. It updates React state
C. It throws an error in React
D. It disables the input