—- How to use it? —-

  • clone this repository to your react app

  • Import validator in your component

  • Use the validation functions in your component on onChange and onBlur events of your input fields

  • Feel free to modify the validation functions to your needs

  • example:
    validating an email field:

          // import validator
          import validator from '../Simple React Form Validation/validationHelpers'
          // use states to store the input value and error message
          const [email, setEmail] = useState('')
          const [emailError, setEmailError] = useState('')
          // inside your form
          <label>Email address</label>
              onChange={(e) => {
              validator.emailInputChangeHandler(, setEmailError)
              onBlur={(e) => {
              validator.emailInputBlurHandler(, setEmailError)
          // Your error message goes here
          <span className='text-danger fs-6'>

—- Found a bug? —-

Feel free to open an issue on github.

—- Want to contribute? —-

Great! fork this repository and make a pull request?.


View Github