1.0.1 • Published 2 years ago

@mohamadtsn/form-validation v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

FormValidation

The best validation library for JavaScript.

FormValidation

Using

  • added this code in index.js(entry point packages file)
window.FormValidation = require("@mohamadtsn/formvalidation/dist/amd/index");
window.FormValidation.plugins.Bootstrap = require("@mohamadtsn/custom/formvalidation/dist/amd/plugins/Bootstrap").default;
window.FormValidation.plugins.Icon = require("@mohamadtsn/custom/formvalidation/dist/amd/plugins/Icon").default;
window.FormValidation.plugins.AutoFocus = require("@mohamadtsn/custom/formvalidation/dist/amd/plugins/AutoFocus").default;
window.FormValidation.locales = require("@mohamadtsn/custom/formvalidation/dist/amd/locales/fa_IR").default;

Declaring validation rules

  • Declarative mode
<form id="registrationForm">
    <input
        name="userName"
        data-fv-not-empty="true"
        data-fv-not-empty___message="The username is required"
        data-fv-string-length="true"
        data-fv-string-length___min="6"
        data-fv-string-length___message="The name must be more than 6 characters long"
    />
</form>
  • Programmatic mode
FormValidation.formValidation(
    document.getElementById('registrationForm'),
    {
        fields: {
            userName: {
                validators: {
                    notEmpty: {
                        message: 'The username is required',
                    },
                    stringLength: {
                        message: 'The name must be more than 6 characters long',
                        min: 6,                        
                    },
                },
            },
        },
    },
);

Integration with your stack

  • Support native form
  • Support popular CSS frameworks via plugins
  • Support popular JavaScript frameworks
  • Easy to integrate with a framework

Play nice with form libraries

  • Autocomplete
  • Color picker
  • Custom checkbox
  • Custom radio
  • Date picker
  • International telephone input
  • Mask input
  • Rich editor
  • Select
  • Star rating
  • Tag input
  • Time picker
  • Toggle
  • Wizard

and more!

Supported browsers

Support the latest version of

  • Chrome
  • Firefox
  • Safari
  • Opera
  • Edge
  • Internet Explorer 11