0.0.7 • Published 3 years ago

native-validator-bootstrap v0.0.7

Weekly downloads
1
License
MIT
Repository
-
Last release
3 years ago

NPM npm npm bundle size npm bundle size

Native Validator Bootstrap

Native JavaScript Form Validator for Bootstrap 4, pure JavasSript solution without jQuery. Sample can be found here

Installation

Install via NPM:

npm install iskandarjamil/native-validator-bootstrap

Usage

import Validator from "native-validator-bootstrap";

new Validator("form");

// or

new Valudator("form", {
  // options
});

Advance Usage

Feel free to add customization, can follow sample like below. Add data-pluginname and data-pluginname-error for error message.

<input type="text" data-numberonly data-numberonly-error="Accept number only." />
import Validator from "native-validator-bootstrap";

Validator.plugin("numberonly", {
  // Optional if want to run something once the Validator created.
  install(el) {},
  // Required, return True/False
  validate(el, attribute) {
    return /^\d+$/.test(el.value);
  },
  // Optional Error message can be define here.
  error(el) {},
});

var validator = new Validator(document.querySelector("form"));

Options

TypeDescriptionDefault
showValidEnable/Disable success input responseTrue
autoScrollEnable/Disable auto scrolling to first errorTrue
delayTimer delay start checking validation after blur event500 (ms)
offsetFocusOffset scrolling for autoScroll50 (ms)

Plugin Included

TypeDescriptionRules
matchCheck equal value between two input, example password matchdata-match
emailSafe email validationdata-email

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT license.

0.0.7

3 years ago

0.0.6

3 years ago

0.0.3

4 years ago

0.0.4

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago