Excluded plugin

Ignore validations on particular field

Usage

This plugin allows you to indicate fields which won't be validated. By default, the plugin will not validate the following kind of fields:
  • disabled
  • hidden
  • invisible
The following piece of code is the starting point to use the Excluded plugin:
<html>
<head>
<link rel="stylesheet" href="/vendors/formvalidation/dist/css/formValidation.min.css" />
</head>
<body>
<form id="demoForm" method="POST">...</form>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.3/es6-shim.min.js"></script>
<script src="/vendors/formvalidation/dist/js/FormValidation.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function(e) {
FormValidation.formValidation(
document.getElementById('demoForm'),
{
fields: {
...
},
plugins: {
excluded: new FormValidation.plugins.Excluded({
excluded: function(field, element, elements) {
// field is the field name
// element is the field element
// elements is the list of field elements in case
// we have multiple elements with the same name
// return true if you want to exclude the field
}
}),
...
},
}
);
});
</script>
</body>
</html>
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.

Basic example

In the following form, there are two invisible fields called Job title and Department. Since they are not visible initially, they will not be validated when you click the Submit button. Clicking the More info button will turn them into visible fields, and as result, they will be required due to their validation rules.
Excluded plugin

See also

Changelog

v1.3.0
  • First release. It means that the Excluded plugin requires FormValidation v1.3.0 or newer