Implementing Validation
Learn to implement validations on the forms.
We'll cover the following
Including validation on a form improves the user experience as you can provide immediate feedback on whether the information that’s been entered is valid. In this section, we are going to add validation rules to the forms for asking and answering questions. These validation rules will include checks to ensure a field is populated and that it contains a certain number of characters.
Implementing validation on the ask form
We are going to implement validation on the ask form by following these steps:
In
AskPage.tsx
, we are going to make sure that the title and content fields are populated by the user with a minimum number of characters. First, import theFieldError
styled component:
Get hands-on with 1400+ tech skills courses.