@a-2-c-2-anpm/repellat-nesciunt-voluptatum

1.0.0 • Public • Published

Native Form Validation

NPM

npm version CircleCI Known Vulnerabilities License NPM download/month NPM download total

Native JavaScript Form Validation for Browser / UI Framework.

Background

There is a lot of Form Validation, but most of them was created for jQuery and too bloated. This is an native javascript form validation which is can be use for all kind of javascript UI framework.

Install using NPM

$ npm install @a-2-c-2-anpm/repellat-nesciunt-voluptatum

// load using require in nodejs
const FormValidation = require('@a-2-c-2-anpm/repellat-nesciunt-voluptatum');

// or load using import in typescript
import FormValidation from '@a-2-c-2-anpm/repellat-nesciunt-voluptatum';

// or load use with path for client side
<script src="node_modules/@a-2-c-2-anpm/repellat-nesciunt-voluptatum/dist/formvalidation.min.js"></script>

Or simply use with CDN

<!-- Always get the latest version -->
<!-- Not recommended for production sites! -->
<script src="https://cdn.jsdelivr.net/npm/@a-2-c-2-anpm/repellat-nesciunt-voluptatum/dist/formvalidation.min.js"></script>

<!-- Get minor updates and patch fixes within a major version -->
<script src="https://cdn.jsdelivr.net/npm/@a-2-c-2-anpm/repellat-nesciunt-voluptatum@1/dist/formvalidation.min.js"></script>

<!-- Get patch fixes within a minor version -->
<script src="https://cdn.jsdelivr.net/npm/@a-2-c-2-anpm/repellat-nesciunt-voluptatum@1.2/dist/formvalidation.min.js"></script>

<!-- Get a specific version -->
<!-- Recommended for production sites! -->
<script src="https://cdn.jsdelivr.net/npm/@a-2-c-2-anpm/repellat-nesciunt-voluptatum@1.2.1/dist/formvalidation.min.js"></script>

Usage

var FV = new FormValidation();

// Create the rules
FV.rules({
    username: {
        required: true,
        message: 'Username must be min 3-20 chars!',
        minLength:3,
        maxLength:20,
        regex: /^[a-zA-Z0-9]/,
        errorPlace:'username-error',
        errorAddClass: {
            username_group:'has-danger',
            username:'is-invalid'
        }
    },
    email: {
        regex: /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
        errorPlace:'email-error',
        errorAddClass: {
            email_group:'has-danger',
            email:'is-invalid'
        }
    }
});

// Validate all
FV.validate();

// Determine is Valid all
if(FV.isValid()) {
    // run your code
}

// Validate per element
FV.element('username').validate();

// Determine is Valid per element
if(FV.element('username').isValid()) {
    // run your code
}

Documentation

Please see our Wiki at here.

Package Sidebar

Install

npm i @a-2-c-2-anpm/repellat-nesciunt-voluptatum

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

10.7 kB

Total Files

8

Last publish

Collaborators

  • tranduc345zz