Tachyons plugin

Integrate with Tachyons library. Support Tachyons v4.10.0

Usage

The following piece of code is the starting point to validate the form made in Tachyons:




    
    


    
...
document.addEventListener('DOMContentLoaded', function(e) { FormValidation.formValidation( document.getElementById('demoForm'), { fields: { ... }, plugins: { tachyons: new FormValidation.plugins.Tachyons(), ... }, } ); });

The sample code above assumes that the FormValidation files are placed inside the vendors directory. You might need to change the path depending on where you place them on the server.

The next sections list out some examples of various forms made with Tachyons.

Horizontal form

Stacked form

You need to add the fv-stacked-form class to the form element such as:


...

In order to add the correct class for error message and the field element when it is a valid or invalid, we need to specify the CSS selector of the field container.

By default, the Tachyons plugin will look for the .fl element. But in the stacked form below, every field will be placed inside our own .row container.

We need to use the rowSelector option to help the plugin determine the field containers as following:


semantic: new FormValidation.plugins.Semantic({
    rowSelector: function(field, ele) {
        // field is the field name
        // ele is the field element
        return '.row';
    }

    // Or you can just simply pass it as a string:
    // rowSelector: '.row',
}),

Multiple fields on the same row