Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.

Unit 4 MCQs Form Handling and Validation

INT252 — Web App Development With Reactjs 60 questions. Pick an option to check it.

Read the notes Subjective questions

0 of 60 answered 0 right 0 wrong , 60 left

  1. Question 1 of 60 Controlled and uncontrolled components Easy

    In React, what makes a form input a controlled component?

  2. Question 2 of 60 Controlled and uncontrolled components Easy

    Which React feature is commonly used to access the current value of an uncontrolled input?

  3. Question 3 of 60 Form state management patterns Easy

    Which React Hook is commonly used to manage a simple form field value?

  4. Question 4 of 60 Form state management patterns Easy

    What is a common way to manage several related form fields in one state value?

  5. Question 5 of 60 Handling form submission workflows Easy

    Which form event is normally handled when a React form is submitted?

  6. Question 6 of 60 Handling form submission workflows Easy

    Why is event.preventDefault() commonly called in a React form submission handler?

  7. Question 7 of 60 Reusable form component design Easy

    How can a reusable input component receive its label text?

  8. Question 8 of 60 Reusable form component design Easy

    What is a key benefit of creating reusable form field components?

  9. Question 9 of 60 Conditional rendering in form interfaces Easy

    What does conditional rendering allow a React form to do?

  10. Question 10 of 60 Conditional rendering in form interfaces Easy

    Which JSX expression displays an error message only when error has a truthy value?

  11. Question 11 of 60 Accessibility considerations in form handling Easy

    Which HTML element should identify the purpose of a form input for users and assistive technologies?

  12. Question 12 of 60 Accessibility considerations in form handling Easy

    Which attribute can indicate to assistive technologies that an input currently has an invalid value?

  13. Question 13 of 60 Client-side form validation concepts Easy

    Where does client-side form validation normally run?

  14. Question 14 of 60 Client-side form validation concepts Easy

    Why should an application still validate form data on the server?

  15. Question 15 of 60 Commonly used validation patterns Easy

    Which validation rule checks that a field is not left empty?

  16. Question 16 of 60 Commonly used validation patterns Easy

    Which validation pattern is commonly used for a password confirmation field?

  17. Question 17 of 60 Schema-based validation principles Easy

    What does a validation schema describe?

  18. Question 18 of 60 Schema-based validation principles Easy

    What is one benefit of using a shared validation schema?

  19. Question 19 of 60 Form validation using Zod Easy

    Which Zod expression defines a required string value?

  20. Question 20 of 60 Integrating schema validation with form logic and error handling Easy

    What is a useful result of calling Zod's safeParse when validating form data?

  21. Question 21 of 60 Controlled and uncontrolled components Medium

    A React text input receives its value from component state. Users can type into the input, but the displayed text never changes. Which change most directly fixes the problem?

  22. Question 22 of 60 Controlled and uncontrolled components Medium

    A form contains a file input and should access the selected file only when the user submits the form. Which approach is most appropriate?

  23. Question 23 of 60 Form state management patterns Medium

    A form stores all field values in one object named formData. Which update correctly changes only the email field without removing the other fields?

  24. Question 24 of 60 Form state management patterns Medium

    Several inputs share one change handler and each input has a unique name attribute. Which expression should the handler use to update the matching property in state?

  25. Question 25 of 60 Handling form submission workflows Medium

    A React form should validate data and send it with fetch without causing a page reload. What should the submit handler do first?

  26. Question 26 of 60 Handling form submission workflows Medium

    A registration form sends an asynchronous request. Which workflow best prevents accidental duplicate submissions?

  27. Question 27 of 60 Reusable form component design Medium

    A reusable TextField component must display a label, an input, and an error message. Which API best supports reuse across forms?

  28. Question 28 of 60 Reusable form component design Medium

    A custom input component must allow its parent form to focus the underlying DOM input after validation fails. Which React design is most suitable?

  29. Question 29 of 60 Conditional rendering in form interfaces Medium

    A shipping-address section should appear only when useBillingAddress is false. Which JSX condition expresses this requirement?

  30. Question 30 of 60 Conditional rendering in form interfaces Medium

    A form conditionally removes a required companyName field when the user selects "Personal account". What should the form logic generally do with that hidden field?

  31. Question 31 of 60 Accessibility considerations in form handling Medium

    A text input shows the error message "Email is required" in an element with id="email-error". Which input attribute best creates an accessible relationship to that message?

  32. Question 32 of 60 Accessibility considerations in form handling Medium

    After a failed submission, which behavior most improves keyboard and screen-reader usability when several fields are invalid?

  33. Question 33 of 60 Client-side form validation concepts Medium

    A checkout form validates card details in the browser before sending them to the server. Why must the server still validate the submitted data?

  34. Question 34 of 60 Client-side form validation concepts Medium

    A form currently displays validation errors after every keystroke, distracting users before they finish typing. Which strategy offers a more balanced experience?

  35. Question 35 of 60 Commonly used validation patterns Medium

    A password confirmation field must match the password field. What kind of validation is required?

  36. Question 36 of 60 Commonly used validation patterns Medium

    A form accepts an optional website URL. Which rule correctly handles an empty value?

  37. Question 37 of 60 Schema-based validation principles Medium

    A team uses the same user schema to validate form data and infer TypeScript types. What is the main benefit of this approach?

  38. Question 38 of 60 Schema-based validation principles Medium

    A signup form requires password and confirmPassword to match. Why is object-level schema validation appropriate?

  39. Question 39 of 60 Form validation using Zod Medium

    Given const schema = z.object({ age: z.coerce.number().int().min(18) }), what happens when it validates { age: "21" }?

  40. Question 40 of 60 Integrating schema validation with form logic and error handling Medium

    A submit handler uses const result = schema.safeParse(formData). What should it do when result.success is false?

  41. Question 41 of 60 Controlled and uncontrolled components Hard

    A file input is implemented as a controlled React input by assigning value={fileName} and updating fileName after onChange. What is the most accurate issue with this design?

  42. Question 42 of 60 Controlled and uncontrolled components Hard

    A controlled text input initially receives value={undefined} and later receives value="admin@example.com". Which behavior should be expected?

  43. Question 43 of 60 Form state management patterns Hard

    A form stores values, touched, errors, isSubmitting, and submitError in separate state variables. Several event handlers update multiple variables based on the previous form state. Which refactoring most directly reduces inconsistency risk?

  44. Question 44 of 60 Form state management patterns Hard

    A field update handler is written as setValues({ ...values, [name]: value }), and two updates are queued during the same event. What change best guarantees that both updates use the latest state?

  45. Question 45 of 60 Handling form submission workflows Hard

    A React form submits data through fetch, but the page still navigates and the browser performs a native submission. Which correction is required?

  46. Question 46 of 60 Handling form submission workflows Hard

    A user submits a form twice before the first request finishes. Which design most reliably prevents an older response from overwriting newer state?

  47. Question 47 of 60 Reusable form component design Hard

    A reusable TextField component needs to support labels, descriptions, errors, arbitrary input attributes, and stable accessibility relationships. Which API design is strongest?

  48. Question 48 of 60 Reusable form component design Hard

    A reusable form component exposes onSubmit, onChange, and errors, but it also silently converts server errors into local field errors. What is the main design concern?

  49. Question 49 of 60 Conditional rendering in form interfaces Hard

    A billing address section is conditionally removed when sameAsShipping becomes true. When it is shown again, its previous values are gone. Which explanation is most accurate?

  50. Question 50 of 60 Conditional rendering in form interfaces Hard

    A payment form renders card fields when method === "card" and bank fields otherwise. Both branches contain an input with the same position but different meanings. What prevents React from incorrectly reusing field state?

  51. Question 51 of 60 Accessibility considerations in form handling Hard

    A field has an inline validation message that appears after blur. Which implementation best communicates the error to assistive technologies?

  52. Question 52 of 60 Accessibility considerations in form handling Hard

    A form displays a server-side error summary after submission. What behavior most improves keyboard and screen-reader usability?

  53. Question 53 of 60 Client-side form validation concepts Hard

    Why should client-side validation be treated as a usability feature rather than a security boundary?

  54. Question 54 of 60 Commonly used validation patterns Hard

    A password confirmation rule reports an error while the user is still typing the first password. Which validation strategy generally gives the best experience without weakening final correctness?

  55. Question 55 of 60 Commonly used validation patterns Hard

    A numeric field accepts "", "0", and "12" as strings. Which approach avoids incorrectly treating zero as missing while still recognizing an empty field?

  56. Question 56 of 60 Schema-based validation principles Hard

    A schema is used both to validate a form and to transform a text field into a number. What architectural property is most important when using the parsed result?

  57. Question 57 of 60 Schema-based validation principles Hard

    A registration schema validates password and confirmPassword independently, but never checks that they match. What kind of rule is missing?

  58. Question 58 of 60 Form validation using Zod Hard

    In Zod, a form field is received from an HTML input as a string, but the domain model requires a positive integer. Which schema best expresses the requirement?

  59. Question 59 of 60 Form validation using Zod Hard

    A Zod object uses .refine() to ensure confirmPassword matches password, but the resulting issue appears at the form root. Which option gives the best field-level error display?

  60. Question 60 of 60 Integrating schema validation with form logic and error handling Hard

    A form calls schema.parse(values) inside an asynchronous submit handler. Invalid input throws before the handler can populate field errors. Which integration pattern is appropriate?

That's unit 4

Answer a few questions and your score shows up here.