//valid.js

@@ -4,8 +4,1430 @@
 alid.js%0A
+%0Avar valid = function( el ) %7B%0A    // jquery the selector%0A    var $el = $( el );%0A    // narrow selection to only these validations%0A    var $els = $el.find( '%5Bdata-pattern%5D, %5Bdata-required%5D' );%0A    // storage array to return%0A    var arr = %5B%5D;%0A%0A    // check for errors%0A    var hasError = function( element ) %7B%0A        // jquery the selector%0A        var $element = $( element );%0A        // trim the whitespace on inputs%0A        var $value = $.trim( $element.val() );%0A        // set the default error%0A        var error = false;%0A%0A        // test the regex pattern%0A        if ( $element.data( 'pattern' ) ) %7B%0A            var regex = new RegExp( $element.data( 'pattern' ) );%0A            // test() will return true for a match%0A            // want to reverse that so it reads like english%0A            // i.e. if there is an error, set error to true%0A            error = ! regex.test( element.value );%0A        %7D%0A%0A        // this will check for an empty value%0A        // covers the required case%0A        if ( $value.length === 0 ) %7B%0A            error = true;%0A        %7D%0A%0A        return error;%0A    %7D;%0A%0A    $.each( $els, function() %7B%0A        var $el = $( this );%0A        if ( hasError( $el ) ) %7B%0A            arr.push(%7B%0A                'type' : $el.attr( 'type' ),%0A                'element' : $el,%0A                'error' : ( $el.data( 'required' ) !== null ) ? 'required' : 'invalid'%0A            %7D);%0A        %7D%0A    %7D);%0A    return arr;%0A%7D;%0A

Add library code