Realtime Form Validation Engine In jQuery - Checkify

Realtime Form Validation Engine In jQuery - Checkify
File Size: 35.9 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Checkify is a jQuery based form validator that provides realtime, client-side, mobile-friendly validation functionalities on form fields.

The plugin highligihts the invalid form fields and displays custom error messages in a tooltip popup. Word perfectly with Bootstrap framework.

Available validators:

  • Required
  • Max/min length.
  • Is number.
  • Is email.
  • REGEX.

How to use it:

1. Import the jQuery Checkify plugin's files into the document.

<link rel="stylesheet" href="/dist/checkify.css">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" 
        integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" 
        crossorigin="anonymous"></script>
<script src="/dist/checkify.js"></script>

2. Apply validation rules to your form fields using the data-checkify attribute:

  • required
  • minlen
  • maxlen
  • number
  • email
  • regex
<div class="myForm">
  <input type="text" class="form-control" data-checkify="minlen=2,required" />
</div>
<div class="myForm">
  <input type="text" class="form-control" data-checkify="maxlen=4,number" />
</div>
<div class="myForm">
  <input type="text" class="form-control" data-checkify="number" />
</div>
<div class="myForm">
  <textarea class="form-control" data-checkify="maxlen=5"></textarea>
</div>
...

3. Activate the form validator and done.

$('form').checkify({

  // specify the trigger element
  // useful for multiple forms on the page
  container: null,

  // realtime validation
  // default: false
  realTime: true
  
});

4. Customize the error messages when invalid.

$('form').checkify({

  message: {

    inactive: false,
    // if true. error message won't be shown for required cases
    inactiveForRequired: true,
    // horizontal gap for error message box
    hGap: null,
    // vertical gap for error message box
    vGap: null,
    // can be right or left
    position: 'left',
    required: 'This field is required.',
    email: 'Please enter a valid email address.',
    regex: 'Invalid data.',
    number: 'Please enter a valid number.',
    maxlen: 'Please enter no more than {count} characters.',
    minlen: 'Please enter at least {count} characters.',
    maxChecked: 'Maximum {count} options allowed.',
    minChecked: 'Please select at least {count} options.',
    notEqual: 'Please enter the same value again.',
    different: 'Fields cannot be the same as each other'

  }

});

5. Available callbacks which will be fired when the form is valid or invalid

$('form').checkify({

  onError: function () {
    console.log('error');
  },
  onValid: function (e, x) {
    console.log(e, x);
    e.preventDefault();

    console.log('valid');
  }

});

Changelog:

2018-10-10

  • v0.0.6: Added validation using custom function

This awesome jQuery plugin is developed by digitalify. For more Advanced Usages, please check the demo page or visit the official website.