DEV Community

Cover image for πŸ”§ Easy Form Validation in React with react-form-validator-pro! πŸ’»
Mahmudur Rahman
Mahmudur Rahman

Posted on

πŸ”§ Easy Form Validation in React with react-form-validator-pro! πŸ’»

Hey, devs! πŸ‘‹

I'm excited to share a lightweight and powerful form validation solution for your React appsβ€”react-form-validator-pro! πŸš€

Why You Should Use It:
βœ… Simple Validation: Just pass in the validation rules, and it automatically handles form field validation.

βœ… Customizable: Easily add your custom validation rules.

βœ… Error Handling: Clear error messages, customizable error placement, and it works seamlessly on both change and blur events.

βœ… Fast Setup: Quick to integrate and use.

Key Features:

  • Built-in validations for common fields like email, password, and phone numbers.
  • Custom validation functions for any complex logic.
  • Supports error messages above or below the form fields.
  • Highly customizable styling options to fit your design.

Check out this example usage:

<FormValidator
  onSubmit={handleSubmit}
  validations={{
    email: { required: true, pattern: /^[^\s@]+@[^\s@]+\.[^\s@]+$/, message: 'Invalid email' },
    password: { required: true, message: 'Password is required', minLength: 8, },
  }}
>
  <div>
    <label>Email:</label>
    <input type="email" name="email" />
  </div>
  <div>
    <label>Password:</label>
    <input type="password" name="password" />
  </div>
  <button type="submit">Submit</button>
</FormValidator>

Enter fullscreen mode Exit fullscreen mode

Install

npm i react-form-validator-pro
Enter fullscreen mode Exit fullscreen mode

NPM
Repository

Github
Repository

No more messy validation logic! This package makes form validation simple and elegant in React.
Follow for more!

Top comments (0)