opendevs
opendevs logo
CoursesInterviewsBlogs

Form Validation

Solidify your knowledge of Forms in React by solving this problem.

Jetha Lal is working on a new component for login, where he is supposed to do these basic validations.

  • Username should be at least 5 characters long
  • Password should be at least 8 characters long
  • Button should be disabled if any of the above validation fails

Help him complete this component using useState and useEffect hook. Once the form is valid, the button should be enabled and on click of it, it should show an alert saying "Login Successful".

Hint 1: Apart from maintaining local state for username and password, you may need to maintain a local state of the form validity. Hint 2: You need to use onInput event to update value of username and password.


Solve this medium problem to earn  2  DevCoin image
Output
Coding Area
opendevs logo
CoursesFAQsContact UsPrivacy PolicyTerms Of Service
Copyright © 2023 opendevs
Learn ● Develop ● Ace
All illustrations by Storyset