1

In angular2, if we want to implement form validation we will use Directives. In React, how can we achieve this validations ???

1

3 Answers 3

2

There are several ways:

  1. Create your own validation from scratch with plain javascript
  2. Use browser APIs
  3. Or you can use 3rd party plugins like 'ract-validation': https://github.com/Lesha-spr/react-validation
Sign up to request clarification or add additional context in comments.

Comments

2

After struggling with too many libraries on web, here is the one I have found more helpful in entire react world. It can make developers more productive by simplifying validation job.

Try using : Formik

npm install formik --save

Why you should use : It will saves you writing too much boggy JSX (involving annoying properties) and dealing directly with underline handling (writing own onBlur() onChange() event handlers) just to achieve validation.

Formik is a small library that helps you with the 3 most annoying parts:

  • Getting values in and out of form state
  • Validation and error messages
  • Handling form submission

By colocating all of the above in one place, Formik will keep things organized--making testing, refactoring, and reasoning about your forms a breeze.

Comments

0

You should try Formik. I am currently working with it in a project and it goes quite well.

As per their readme.md in github they say: "Formik is a small library that helps you with the 3 most annoying parts:

Getting values in and out of form state Validation and error messages Handling form submission By colocating all of the above in one place, Formik will keep things organized--making testing, refactoring, and reasoning about your forms a breeze."

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.