Foundation plugin

Integrate with the Foundation framework
The plugin supports Foundation v6.5.3.


The following piece of code is the starting point to validate the form made in Foundation:
<link rel="stylesheet" href="" />
<link rel="stylesheet" href="/vendors/formvalidation/dist/css/formValidation.min.css" />
<form id="demoForm" method="POST">...</form>
<script src=""></script>
<script src="/vendors/formvalidation/dist/js/FormValidation.min.js"></script>
<script src="/vendors/formvalidation/dist/js/plugins/Foundation.min.js"></script>
document.addEventListener('DOMContentLoaded', function(e) {
fields: {
plugins: {
foundation: new FormValidation.plugins.Foundation(),
There are some important things here:
  • 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.
  • Foundation.min.js is the plugin provided by FormValidation. It is NOT the same as Foundation(.min).js file provided by the Foundation framework.
The next sections list out some examples of various forms made with Foundation.

Horizontal form

Horizontal form

Stacked form

You need to add the fv-stacked-form class to the form element such as:
<form class="fv-stacked-form">
<!-- The fields go here -->
Stacked form

Multiple fields on the same row

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 Foundation plugin will look for the .grid-x element. In the following example, the firstName and lastName fields are placed inside .small-4 containers. Meanwhile, the city, state and zipcode fields can be found inside the .small-3 containers.
The rowSelector option will be used to help the plugin determine the field containers as following:
foundation: new FormValidation.plugins.Foundation({
rowSelector: function(field, ele) {
// field is the field name
// ele is the field element
switch (field) {
case 'firstName':
case 'lastName':
return '.small-4';
case 'city':
case 'state':
case 'zipcode':
return '.small-3';
return '.form-group';
Multiple fields on the same row


  • First release