Vanilla JavaScript Form Validator For Bootstrap Framework

Category: Form , Javascript | February 26, 2019
Author: PascaleBeier
Views Total: 1,448
Official Page: Go to website
Last Update: February 26, 2019
License: MIT

Preview:

Vanilla JavaScript Form Validator For Bootstrap Framework

Description:

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.

You Might Be Interested In:


Leave a Reply