Quantcast
Viewing all articles
Browse latest Browse all 162

Vanilla JavaScript Form Validator For Bootstrap Framework

Image may be NSFW.
Clik here to view.
bootstrap-validate

A vanilla JavaScript plugin that adds the form validation functionality to your Bootstrap project without any 3rd JS libraries.

How to use it:

Load the Bootstrap’s stylesheet and the JavaScript file ‘bootstrap-validate.js’ in the webpage.

<link rel="stylesheet" href="bootstrap.min.css">
<script src="bootstrap-validate.js"></script>

Initialize the Bootstrap validate library and apply a validation rule of your choice to the form field:

<input id="input" type="text" class="form-control">
bootstrapValidate(
  '#input',
  'required:fill out this field'
);

You’re also allowed to apply multiple validation rules to the same form field as this:

bootstrapValidate(
  '#input',
  'required:fill out this field|email:Enter a valid email address|min:10:Enter at least 10 Characters|max:300:Enter at max 300 chars'
);

Changelog:

v2.2.0 (02/26/2019)

  • Added new inArray Rule, allowing to validate an input against an array of strings.

The post Vanilla JavaScript Form Validator For Bootstrap Framework appeared first on CSS Script.


Viewing all articles
Browse latest Browse all 162

Trending Articles