Integrating with Mithril

This page will help you integrate FormValidation with the Mithril framework.

For the sake of simplicity, we are about to validate a simple login form with just two fields to input the username and password:

It's recommened to put the form inside a component:

Creating a FormValidation instance

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

Destroying FormValidation instance

Mithril component triggers the onremove event when it's removed from page or not used anymore. It's the time to destroy our FormValidation instance by using the destroy() method:

More examples