Install

Install with Bower:
    bower install input-validator.js
    
Or clone from Github:
    git clone https://github.com/rtivital/validate.git
    
Include library before closing body tag
    <body>
      ...
      <script src="input-validator.min.js"></script>
    </body>
    

Validate

Basic email validation example

Enter your email adress

Code for this validation

var emailInput = new Validator.init(document.getElementById('email'), {
  rules: {
    min: 5,
    max: 20,
    match: 'email'
  },
  onError: onError,
  onSuccess: onSuccess
});

var validateEmailBtn = document.getElementById('validate-email');
validateEmailBtn.addEventListener('click', function(e) {
  emailInput.validate();
}, false);
<div class="input-group center-block">
  <label for="email">Your email address:</label>
  <input type="text" class="form-control" id="email" placeholder="example@email.com">
  <span id="email-error-container" class="help-block">Enter your email adress</span>
  <button class="btn btn-default" id="validate-email">Validate email address</button>
</div>