API

A collection of public methods
After initializing the form with FormValidation.formValidation(), you can access the public methods provided by formValidation.

Using the global script in the browser

<script src="/vendors/@form-validation/umd/bundle/popular.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function(e) {
const fv = FormValidation.formValidation(
document.getElementById('demoForm'),
{
...
}
);
// Call the public methods
fv.METHOD_NAME(PARAMETERS);
});
</script>

Using the ES6 module

// You might need to change the importing path
import { formValidation } from '/path/to/@form-validation/cjs/bundle/popular';
// Initialize somewhere depending on the JavaScript framework you are using
const fv = formValidation(
document.getElementById('demoForm'),
{
...
}
);
// Call the public methods
fv.METHOD_NAME(PARAMETERS);

Using the npm package

  • Install the bundle package:
$ npm install @form-validation/bundle
  • Use the formValidation instance:
import { formValidation } from '@form-validation/bundle/popular';
// Initialize somewhere depending on the JavaScript framework you are using
const fv = formValidation(
document.getElementById('demoForm'),
{
...
}
);
// Call the public methods
fv.METHOD_NAME(PARAMETERS);
The next sections list all of the public methods provided by the library.