IV.js - for all your input validation needs

About

This library was created to provide a intutive way to provide validation filters that are usefull in processing user input. The methods in this library can be easily selected right on the DOM to give a native feel to the input element tags. Feel free to help out and contribute to the list in the repository at github.com

Live example:

Useage

  • Step #1: the HTML

    The only thing IV.js looks for that may differ from your normal form is the addition of a a few attribute tags. Primarily, adding the IValidate class to the form signals the library to apply it's callbacks to the element

    Example form:

    
    <form action="something" method="post">    
        <!-- first, a basic input with "cant-be-empty" (default) -->
        <input type="text" class="IValidate" name="displayname">
        
        <!-- next, am email input with the email filter -->
        <input type="text" class="IValidate" name="email" data-filter="email">
        
        <!-- now, an input with a placeholder! -->
        <input type="text" class="IValidate" name="birthday" data-filter="any" data-placeholder="MM/YY">
        
        <!-- lastly, add the trigger button -->
        <input type="button" class="IValidator" value="go">
    </form>    
                                    
  • Step #2: the JavaScript

    Keeping in mind that jquery is required for this library, our page now has everything we need to get started setting up the inputs to their correct methods. To do so the most simple way, we add this code to our page inside a <script> tag:

    
    var validator;
    $(document).ready(function(){
        validator = new IV();
    });
                                    

    With this little bit of code, IV.js finds all of the forms on the page with the appropriate class definitions, ad applys the IV.js filters to the form's input elements.