Put in order · JavaScript and React course · Module 3: State and Events

Form Validation Step by Step

Arrange the validation steps of the MissionPlanner form from the lesson on event handling:

Items to put in order

  • The user submits the form
  • validateForm() checks the fields and stores the errors in the errors state
  • The component re-renders and shows messages next to the invalid fields
  • The user corrects a field and handleChange removes its error from the state
  • handleSubmit calls e.preventDefault()

You can check the correct answer by solving this task in the CodeWorlds game.