Integrating with Preact

This page will help you integrate FormValidation with the Preact library. For the sake of simplicity, we are about to validate a simple login form with just two fields to input the username and password:

Bundling the library First of all, you need to look at the following guide to see how we can bundle FormValidation with popular bundlers: Bundling with Rollup

Bundling with Webpack

Creating a FormValidation instance The best place to initialize a FormValidation instance is inside the component's componentDidMount event:

Using the plugins In order to use the plugins, we need to import them: Now the FormValidation instance is ready, you can listen on the events or call API:

Registering validator You don't need to follow this section if you are using a popular validator. The popular validator is ready when you import the FormValidation's core: In the other cases, you have to use the registerValidator() method to let the library knows where it can find a special or custom validator: