Bug Tracker

Changeset 4329

Show
Ignore:
Timestamp:
12/28/07 16:40:03 (1 year ago)
Author:
joern.zaefferer
Message:

fixed dynamic inputs demo; started incorporting delegate plugin

Location:
trunk/plugins/validate
Files:
2 added
8 modified

Legend:

Unmodified
Added
Removed
  • trunk/plugins/validate/demo/dynamic-totals.html

    r4056 r4329  
    99<script src="../lib/jquery.js" type="text/javascript"></script> 
    1010<script src="../lib/jquery.metadata.js" type="text/javascript"></script> 
     11<script type="text/javascript" src="../lib/jquery.delegate.js"></script> 
    1112<script src="../jquery.validate.js" type="text/javascript"></script> 
    1213 
     
    5859    addRow(); 
    5960     
     61    // TODO use keyup on form to update 
    6062    $("body").change(function(event) { 
    6163        if ( $(event.target).parent().is(".quantity") ) { 
     
    131133                <tr> 
    132134                    <td colspan="2"><label>Totals</label></td> 
    133                     <td class="totals"><input id="totals" name="totals" value="0" readonly="readonly" disabled="disabled" size='4' /></td> 
     135                    <td class="totals"><input id="totals" name="totals" value="0" readonly="readonly" size='4' /></td> 
    134136                </tr> 
    135137                <tr> 
  • trunk/plugins/validate/jquery.validate.js

    r4325 r4329  
    269269        } else { 
    270270            var valid = true; 
    271             var validator = jQuery(this.form).validate(); 
     271            var validator = jQuery(this[0].form).validate(); 
    272272            this.each(function() { 
    273273                valid = validator.element(this) && valid; 
     
    278278    // destructive add 
    279279    push: function( t ) { 
    280         return this.setArray( jQuery.merge( this.get(), t ) ); 
     280        return this.setArray( this.add(t).get() ); 
    281281    } 
    282282}); 
     
    402402        onsubmit: true, 
    403403        ignore: [], 
    404         onblur: function(element) { 
     404        onfocusin: function(element) { 
     405            this.lastActive = element; 
     406                 
     407            // hide error label and remove error class on focus if enabled 
     408            if ( this.settings.focusCleanup && !this.blockFocusCleanup ) { 
     409                this.settings.unhighlight.call( this, element, this.settings.errorClass ); 
     410                this.errorsFor(element).hide(); 
     411            } 
     412        }, 
     413        onfocusout: function(element) { 
    405414            if ( !this.checkable(element) && (element.name in this.submitted || !this.optional(element)) ) { 
    406415                this.element(element); 
     
    667676        refresh: function(selection) { 
    668677            var validator = this; 
    669             validator.rulesCache = {}; 
    670678             
    671             function focused() { 
    672                 validator.lastActive = this; 
    673                  
    674                 // hide error label and remove error class on focus if enabled 
    675                 if ( validator.settings.focusCleanup && !validator.blockFocusCleanup ) { 
    676                     jQuery(this).removeClass( validator.settings.errorClass ); 
    677                     validator.errorsFor(this).hide(); 
    678                 } 
    679             } 
    680  
    681679            // check for partial refresh 
    682680            if ( selection ) { 
    683681                jQuery(selection).each(function() { 
    684                     if ( validator.elements.index(this) > -1 ) { 
    685                         validator.elements.add(this); 
     682                    if ( validator.elements.index(this) == -1 ) { 
     683                        validator.elements.push(this); 
    686684                    } 
    687685                    validator.rulesCache[this.name] = validator.rules(this); 
    688                 }).focus(focused); 
    689             } 
     686                }); 
     687                return; 
     688            } 
     689             
     690            validator.rulesCache = {}; 
    690691             
    691692            // select all valid inputs inside the form (no submit or reset buttons) 
    692             this.elements = jQuery(this.currentForm) 
    693             .find("input, select, textarea") 
    694             .not(":submit, :reset") 
    695             .not("[@disabled]") 
     693            this.elements = jQuery(this.currentForm.elements) 
     694            .filter("input, select, textarea") 
     695            .not(":submit, :reset, [disabled]") 
    696696            .not( this.settings.ignore ) 
    697697            .filter(function() { 
     
    708708             
    709709            // and listen for focus events to save reference to last focused element 
    710             this.elements.focus(focused); 
    711              
    712             validator.settings.onblur && validator.elements.blur( function() { 
    713                 validator.settings.onblur.call( validator, this ); 
    714             }); 
    715             validator.settings.onkeyup && validator.elements.keyup(function() { 
    716                 validator.settings.onkeyup.call( validator, this ); 
     710            jQuery(this.currentForm).delegate("focusin focusout keyup", "input, select, textarea", function(event) { 
     711                validator.settings["on" + event.type].call(validator, this[0] ); 
    717712            }); 
    718713             
     
    759754            element = this.clean( element ); 
    760755            this.settings.unhighlight.call( this, element, this.settings.errorClass ); 
    761             //var rules = this.rules( element ); 
    762756            var rules = this.rulesCache[ element.name ]; 
    763757            for( var i = 0; rules[i]; i++) { 
  • trunk/plugins/validate/lib/jquery.delegate.js

    r4324 r4329  
    44 * Copyright (c) 2007 Jörn Zaefferer 
    55 * 
    6  * $Id: jquery.delegate.js 4323 2007-12-28 14:00:16Z joern.zaefferer $ 
     6 * $Id: jquery.delegate.js 4328 2007-12-28 16:39:00Z joern.zaefferer $ 
    77 * 
    88 * Dual licensed under the MIT and GPL licenses: 
     
    1111 */ 
    1212 
    13 // provides a cross-browser focusin event 
    14 // IE has native support, in other browsers, capture a focus event (doesn't bubble) 
     13// provides cross-browser focusin and focusout events 
     14// IE has native support, in other browsers, use event caputuring (neither bubbles) 
    1515 
    1616// provides delegate(type, delegate, handler) plugin for easier event delegation 
    1717// handler is only called when $(event.target).is(delegate), in the scope of the jQuery-object for event.target  
     18 
     19// provides triggerEvent(type, target) to trigger delegated events 
    1820;(function($) { 
    1921    $.extend($.event.special, { 
     
    3436                return $.event.handle.apply(this, args); 
    3537            } 
     38        }, 
     39        focusout: { 
     40            setup: function() { 
     41                if ($.browser.msie) 
     42                    return false; 
     43                this.addEventListener("blur", $.event.special.focusout.handler, true); 
     44            }, 
     45            teardown: function() { 
     46                if ($.browser.msie) 
     47                    return false; 
     48                this.removeEventListener("blur", $.event.special.focusout.handler, true); 
     49            }, 
     50            handler: function(event) { 
     51                var args = Array.prototype.slice.call( arguments, 1 ); 
     52                args.unshift($.extend($.event.fix(event), { type: "focusout" })); 
     53                return $.event.handle.apply(this, args); 
     54            } 
    3655        } 
    3756    }); 
     
    4463                } 
    4564            }); 
     65        }, 
     66        triggerEvent: function(type, target) { 
     67            return this.triggerHandler(type, [jQuery.event.fix({ type: type, target: target })]); 
    4668        } 
    4769    }) 
  • trunk/plugins/validate/test/events.html

    r4324 r4329  
    1212<script type="text/javascript"> 
    1313$().ready(function() { 
    14     $("#commentForm").delegate("focusin", ":text, textarea", function() { 
     14    var handler = { 
     15        focusin: function() { 
     16            $(this).addClass("focus"); 
     17        }, 
     18        focusout: function() { 
     19            $(this).removeClass("focus"); 
     20        } 
     21    } 
     22    $("#commentForm").delegate("focusin focusout", ":text, textarea", function(event) { 
     23        /* 
    1524        this.addClass("focus").one("blur", function() { 
    1625            $(this).removeClass("focus"); 
    1726        }); 
     27        */ 
     28        handler[event.type].call(this, arguments); 
    1829    }); 
    1930    $("#remove").click(function() { 
  • trunk/plugins/validate/test/index.html

    r4054 r4329  
    88    <script type="text/javascript" src="../lib/jquery.metadata.js"></script> 
    99    <script type="text/javascript" src="../lib/jquery.ajaxQueue.js"></script> 
     10    <script type="text/javascript" src="../lib/jquery.delegate.js"></script> 
    1011    <script type="text/javascript" src="../jquery.validate.js"></script> 
    1112    <script type="text/javascript" src="../additional-methods.js"></script> 
    1213    <script type="text/javascript" src="test.js"></script> 
     14    <script type="text/javascript" src="methods.js"></script> 
    1315     
    1416    <style type="text/css"> 
  • trunk/plugins/validate/test/test.js

    r4317 r4329  
    11jQuery.validator.defaults.debug = true; 
    2  
    3 function methodTest( method ) { 
    4     var v = jQuery("#form").validate(); 
    5     var method = $.validator.methods[method]; 
    6     var element = $("#firstname")[0]; 
    7     return function(value) { 
    8         element.value = value; 
    9         return method.call( v, value, element ); 
    10     }; 
    11 } 
    12  
    13 module("methods"); 
    14  
    15 test("digit", function() { 
    16     var method = methodTest("digits"); 
    17     ok( method( "123" ), "Valid digits" ); 
    18     ok(!method( "123.000" ), "Invalid digits" ); 
    19     ok(!method( "123.000,00" ), "Invalid digits" ); 
    20     ok(!method( "123.0.0,0" ), "Invalid digits" ); 
    21     ok(!method( "x123" ), "Invalid digits" ); 
    22     ok(!method( "100.100,0,0" ), "Invalid digits" ); 
    23 }); 
    24  
    25 test("url", function() { 
    26     var method = methodTest("url"); 
    27     ok( method( "http://bassistance.de/jquery/plugin.php?bla=blu" ), "Valid url" ); 
    28     ok( method( "https://bassistance.de/jquery/plugin.php?bla=blu" ), "Valid url" ); 
    29     ok( method( "ftp://bassistance.de/jquery/plugin.php?bla=blu" ), "Valid url" ); 
    30     ok( method( "http://bassistance" ), "Valid url" ); 
    31     ok( method( "http://www.føtex.dk/" ), "Valid url, danish unicode characters" ); 
    32     ok( method( "http://bösendorfer.de/" ), "Valid url, german unicode characters" ); 
    33     ok( method( "http://bassistance." ), "Valid url" ); 
    34     ok( method( "http://192.168.8.5" ), "Valid IP Address" ) 
    35     ok(!method( "http://192.168.8." ), "Invalid IP Address" ) 
    36     ok(!method( "http://bassistance,de" ), "Invalid url" ); 
    37     ok(!method( "http://bassistance;de" ), "Invalid url" ); 
    38     ok(!method( "http://.bassistancede" ), "Invalid url" ); 
    39     ok(!method( "bassistance.de" ), "Invalid url" ); 
    40 }); 
    41  
    42 test("email", function() { 
    43     var method = methodTest("email"); 
    44     ok( method( "name@domain.tld" ), "Valid email" ); 
    45     ok( method( "name@domain.tl" ), "Valid email" ); 
    46     ok( method( "bart+bart@tokbox.com" ), "Valid email" ); 
    47     ok( method( "bart+bart@tokbox.travel" ), "Valid email" ); 
    48     ok( method( "n@d.tld" ), "Valid email" ); 
    49     ok( method( "ole@føtex.dk"), "Valid email" ); 
    50     ok( method( "jörn@bassistance.de"), "Valid email" ); 
    51     ok( method( "bla.blu@g.mail.com"), "Valid email" ); 
    52     ok( method( "name@domain" ), "Valid email" ); 
    53     ok( method( "\"Scott Gonzalez\"@example.com" ), "Valid email" ); 
    54     ok( method( "\"Scott González\"@example.com" ), "Valid email" ); 
    55     ok( method( "\"name.\"@domain" ), "Valid email" ); 
    56     ok( method( "\"name,\"@domain" ), "Valid email" ); 
    57     ok( method( "\"name;\"@domain" ), "Valid email" ); 
    58     ok(!method( "name" ), "Invalid email" ); 
    59     ok(!method( "name@" ), "Invalid email" ); 
    60     ok(!method( "name.@domain.tld" ), "Invalid email" ); 
    61     ok(!method( "name,@domain.tld" ), "Invalid email" ); 
    62     ok(!method( "name;@domain.tld" ), "Invalid email" ); 
    63 }); 
    64  
    65 test("number", function() { 
    66     var method = methodTest("number"); 
    67     ok( method( "123" ), "Valid number" ); 
    68     ok( method( "-123" ), "Valid number" ); 
    69     ok( method( "123,000" ), "Valid number" ); 
    70     ok( method( "-123,000" ), "Valid number" ); 
    71     ok( method( "123,000.00" ), "Valid number" ); 
    72     ok( method( "-123,000.00" ), "Valid number" ); 
    73     ok(!method( "123.000,00" ), "Invalid number" ); 
    74     ok(!method( "123.0.0,0" ), "Invalid number" ); 
    75     ok(!method( "x123" ), "Invalid number" ); 
    76     ok(!method( "100.100,0,0" ), "Invalid number" ); 
    77      
    78     ok( method( "" ), "Blank is valid" ); 
    79     ok( method( "123" ), "Valid decimal" ); 
    80     ok( method( "123000" ), "Valid decimal" ); 
    81     ok( method( "123000.12" ), "Valid decimal" ); 
    82     ok( method( "-123000.12" ), "Valid decimal" ); 
    83     ok( method( "123.000" ), "Valid decimal" ); 
    84     ok( method( "123,000.00" ), "Valid decimal" ); 
    85     ok( method( "-123,000.00" ), "Valid decimal" ); 
    86     ok(!method( "1230,000.00" ), "Invalid decimal" ); 
    87     ok(!method( "123.0.0,0" ), "Invalid decimal" ); 
    88     ok(!method( "x123" ), "Invalid decimal" ); 
    89     ok(!method( "100.100,0,0" ), "Invalid decimal" ); 
    90 }); 
    91  
    92 test("numberDE", function() { 
    93     var method = methodTest("numberDE"); 
    94     ok( method( "123" ), "Valid numberDE" ); 
    95     ok( method( "-123" ), "Valid numberDE" ); 
    96     ok( method( "123.000" ), "Valid numberDE" ); 
    97     ok( method( "-123.000" ), "Valid numberDE" ); 
    98     ok( method( "123.000,00" ), "Valid numberDE" ); 
    99     ok( method( "-123.000,00" ), "Valid numberDE" ); 
    100     ok(!method( "123,000.00" ), "Invalid numberDE" ); 
    101     ok(!method( "123,0,0.0" ), "Invalid numberDE" ); 
    102     ok(!method( "x123" ), "Invalid numberDE" ); 
    103     ok(!method( "100,100.0.0" ), "Invalid numberDE" ); 
    104      
    105     ok( method( "" ), "Blank is valid" ); 
    106     ok( method( "123" ), "Valid decimalDE" ); 
    107     ok( method( "123000" ), "Valid decimalDE" ); 
    108     ok( method( "123000,12" ), "Valid decimalDE" ); 
    109     ok( method( "-123000,12" ), "Valid decimalDE" ); 
    110     ok( method( "123.000" ), "Valid decimalDE" ); 
    111     ok( method( "123.000,00" ), "Valid decimalDE" ); 
    112     ok( method( "-123.000,00" ), "Valid decimalDE" ) 
    113     ok(!method( "123.0.0,0" ), "Invalid decimalDE" ); 
    114     ok(!method( "x123" ), "Invalid decimalDE" ); 
    115     ok(!method( "100,100.0.0" ), "Invalid decimalDE" ); 
    116 }); 
    117  
    118 test("date", function() { 
    119     var method = methodTest("date"); 
    120     ok( method( "06/06/1990" ), "Valid date" ); 
    121     ok( method( "6/6/06" ), "Valid date" ); 
    122     ok(!method( "1990x-06-06" ), "Invalid date" ); 
    123 }); 
    124  
    125 test("dateISO", function() { 
    126     var method = methodTest("dateISO"); 
    127     ok( method( "1990-06-06" ), "Valid date" ); 
    128     ok( method( "1990/06/06" ), "Valid date" ); 
    129     ok( method( "1990-6-6" ), "Valid date" ); 
    130     ok( method( "1990/6/6" ), "Valid date" ); 
    131     ok(!method( "1990-106-06" ), "Invalid date" ); 
    132     ok(!method( "190-06-06" ), "Invalid date" ); 
    133 }); 
    134  
    135 test("dateDE", function() { 
    136     var method = methodTest("dateDE"); 
    137     ok( method( "03.06.1984" ), "Valid dateDE" ); 
    138     ok( method( "3.6.84" ), "Valid dateDE" ); 
    139     ok(!method( "6-6-06" ), "Invalid dateDE" ); 
    140     ok(!method( "1990-06-06" ), "Invalid dateDE" ); 
    141     ok(!method( "06/06/1990" ), "Invalid dateDE" ); 
    142     ok(!method( "6/6/06" ), "Invalid dateDE" ); 
    143 }); 
    144  
    145 test("required", function() { 
    146     var v = jQuery("#form").validate(); 
    147     var method = $.validator.methods.required; 
    148         e = $('#text1, #hidden2, #select1, #select2'); 
    149     ok( method.call( v, e[0].value, e[0]), "Valid text input" ); 
    150     ok(!method.call( v, e[1].value, e[1]), "Invalid text input" ); 
    151     ok(!method.call( v, e[2].value, e[2]), "Invalid select" ); 
    152     ok( method.call( v, e[3].value, e[3]), "Valid select" ); 
    153      
    154     e = $('#area1, #area2, #pw1, #pw2'); 
    155     ok( method.call( v, e[0].value, e[0]), "Valid textarea" ); 
    156     ok(!method.call( v, e[1].value, e[1]), "Invalid textarea" ); 
    157     ok( method.call( v, e[2].value, e[2]), "Valid password input" ); 
    158     ok(!method.call( v, e[3].value, e[3]), "Invalid password input" ); 
    159      
    160     e = $('#radio1, #radio2, #radio3'); 
    161     ok(!method.call( v, e[0].value, e[0]), "Invalid radio" ); 
    162     ok( method.call( v, e[1].value, e[1]), "Valid radio" ); 
    163     ok( method.call( v, e[2].value, e[2]), "Valid radio" ); 
    164      
    165     e = $('#check1, #check2'); 
    166     ok( method.call( v, e[0].value, e[0]), "Valid checkbox" ); 
    167     ok(!method.call( v, e[1].value, e[1]), "Invalid checkbox" ); 
    168      
    169     e = $('#select1, #select2, #select3, #select4'); 
    170     ok(!method.call( v, e[0].value, e[0]), "Invalid select" ); 
    171     ok( method.call( v, e[1].value, e[1]), "Valid select" ); 
    172     ok( method.call( v, e[2].value, e[2]), "Valid select" ); 
    173     ok( method.call( v, e[3].value, e[3]), "Valid select" ); 
    174 }); 
    175  
    176 test("required with dependencies", function() { 
    177     var v = jQuery("#form").validate(); 
    178     var method = $.validator.methods.required; 
    179         e = $('#hidden2, #select1, #area2, #radio1, #check2'); 
    180     ok( method.call( v, e[0].value, e[0], "asffsaa"), "Valid text input due to depencie not met" ); 
    181     ok(!method.call( v, e[0].value, e[0], "input"), "Invalid text input" ); 
    182     ok( method.call( v, e[0].value, e[0], function() { return false; }), "Valid text input due to depencie not met" ); 
    183     ok(!method.call( v, e[0].value, e[0], function() { return true; }), "Invalid text input" ); 
    184     ok( method.call( v, e[1].value, e[1], "asfsfa"), "Valid select due to dependency not met" ); 
    185     ok(!method.call( v, e[1].value, e[1], "input"), "Invalid select" ); 
    186     ok( method.call( v, e[2].value, e[2], "asfsafsfa"), "Valid textarea due to dependency not met" ); 
    187     ok(!method.call( v, e[2].value, e[2], "input"), "Invalid textarea" ); 
    188     ok( method.call( v, e[3].value, e[3], "asfsafsfa"), "Valid radio due to dependency not met" ); 
    189     ok(!method.call( v, e[3].value, e[3], "input"), "Invalid radio" ); 
    190     ok( method.call( v, e[4].value, e[4], "asfsafsfa"), "Valid checkbox due to dependency not met" ); 
    191     ok(!method.call( v, e[4].value, e[4], "input"), "Invalid checkbox" ); 
    192 }); 
    193  
    194 test("minLength", function() { 
    195     var v = jQuery("#form").validate(); 
    196     var method = $.validator.methods.minLength, 
    197         param = 2, 
    198         e = $('#text1, #text2, #text3'); 
    199     ok( method.call( v, e[0].value, e[0], param), "Valid text input" ); 
    200     ok(!method.call( v, e[1].value, e[1], param), "Invalid text input" ); 
    201     ok( method.call( v, e[2].value, e[2], param), "Valid text input" ); 
    202      
    203     e = $('#check1, #check2, #check3'); 
    204     ok(!method.call( v, e[0].value, e[0], param), "Valid checkbox" ); 
    205     ok( method.call( v, e[1].value, e[1], param), "Valid checkbox" ); 
    206     ok( method.call( v, e[2].value, e[2], param), "Invalid checkbox" ); 
    207      
    208     e = $('#select1, #select2, #select3, #select4, #select5'); 
    209     ok(method.call( v, e[0].value, e[0], param), "Valid select" ); 
    210     ok(!method.call( v, e[1].value, e[1], param), "Invalid select" ); 
    211     ok( method.call( v, e[2].value, e[2], param), "Valid select" ); 
    212     ok( method.call( v, e[3].value, e[3], param), "Valid select" ); 
    213     ok( method.call( v, e[3].value, e[3], param), "Valid select" ); 
    214 }); 
    215  
    216 test("maxLength", function() { 
    217     var v = jQuery("#form").validate(); 
    218     var method = $.validator.methods.maxLength, 
    219         param = 4, 
    220         e = $('#text1, #text2, #text3'); 
    221     ok( method.call( v, e[0].value, e[0], param), "Valid text input" ); 
    222     ok( method.call( v, e[1].value, e[1], param), "Valid text input" ); 
    223     ok(!method.call( v, e[2].value, e[2], param), "Invalid text input" ); 
    224      
    225     e = $('#check1, #check2, #check3'); 
    226     ok( method.call( v, e[0].value, e[0], param), "Valid checkbox" ); 
    227     ok( method.call( v, e[1].value, e[1], param), "Invalid checkbox" ); 
    228     ok(!method.call( v, e[2].value, e[2], param), "Invalid checkbox" ); 
    229      
    230     e = $('#select1, #select2, #select3, #select4'); 
    231     ok( method.call( v, e[0].value, e[0], param), "Valid select" ); 
    232     ok( method.call( v, e[1].value, e[1], param), "Valid select" ); 
    233     ok( method.call( v, e[2].value, e[2], param), "Valid select" ); 
    234     ok(!method.call( v, e[3].value, e[3], param), "Invalid select" ); 
    235 }); 
    236  
    237 test("rangeLength", function() { 
    238     var v = jQuery("#form").validate(); 
    239     var method = $.validator.methods.rangeLength, 
    240         param = [2, 4], 
    241         e = $('#text1, #text2, #text3'); 
    242     ok( method.call( v, e[0].value, e[0], param), "Valid text input" ); 
    243     ok(!method.call( v, e[1].value, e[1], param), "Invalid text input" ); 
    244     ok(!method.call( v, e[2].value, e[2], param), "Invalid text input" ); 
    245 }); 
    246  
    247 test("minValue", function() { 
    248     var v = jQuery("#form").validate(); 
    249     var method = $.validator.methods.minValue, 
    250         param = 8, 
    251         e = $('#value1, #value2, #value3'); 
    252     ok(!method.call( v, e[0].value, e[0], param), "Invalid text input" ); 
    253     ok( method.call( v, e[1].value, e[1], param), "Valid text input" ); 
    254     ok( method.call( v, e[2].value, e[2], param), "Valid text input" ); 
    255 }); 
    256  
    257 test("maxValue", function() { 
    258     var v = jQuery("#form").validate(); 
    259     var method = $.validator.methods.maxValue, 
    260         param = 12, 
    261         e = $('#value1, #value2, #value3'); 
    262     ok( method.call( v, e[0].value, e[0], param), "Valid text input" ); 
    263     ok( method.call( v, e[1].value, e[1], param), "Valid text input" ); 
    264     ok(!method.call( v, e[2].value, e[2], param), "Invalid text input" ); 
    265 }); 
    266  
    267 test("rangeValue", function() { 
    268     var v = jQuery("#form").validate(); 
    269     var method = $.validator.methods.rangeValue, 
    270         param = [4,12], 
    271         e = $('#value1, #value2, #value3'); 
    272     ok(!method.call( v, e[0].value, e[0], param), "Invalid text input" ); 
    273     ok( method.call( v, e[1].value, e[1], param), "Valid text input" ); 
    274     ok(!method.call( v, e[2].value, e[2], param), "Invalid text input" ); 
    275 }); 
    276  
    277 test("equalTo", function() { 
    278     var v = jQuery("#form").validate(); 
    279     var method = $.validator.methods.equalTo, 
    280         e = $('#text1, #text2'); 
    281     ok( method.call( v, "Test", e[0], "#text1"), "Text input" ); 
    282     ok( method.call( v, "T", e[1], "#text2"), "Another one" ); 
    283 }); 
    284  
    285  
    286 test("method default messages", function() { 
    287     var m = $.validator.methods; 
    288     $.each(m, function(key) { 
    289         ok( jQuery.validator.messages[key], key + " has a default message." ); 
    290     }); 
    291 }); 
    292  
    293 module("additional methods"); 
    294  
    295 test("phone (us)", function() { 
    296     var method = methodTest("phone"); 
    297     ok( method( "1(212)-999-2345" ), "Valid us phone number" ); 
    298     ok( method( "212 999 2344" ), "Valid us phone number" ); 
    299     ok( method( "212-999-0983" ), "Valid us phone number" ); 
    300     ok(!method( "111-123-5434" ), "Invalid us phone number" ); 
    301     ok(!method( "212 123 4567" ), "Invalid us phone number" ); 
    302 }); 
    303  
    304 test("dateITA", function() { 
    305     var method = methodTest("dateITA"); 
    306     ok( method( "01/01/1900" ), "Valid date ITA" ); 
    307     ok(!method( "01/13/1990" ), "Invalid date ITA" ); 
    308     ok(!method( "01.01.1900" ), "Invalid date ITA" ); 
    309 }); 
    3102 
    3113module("validator"); 
     
    501193test("showErrors() - external messages", function() { 
    502194    expect( 4 ); 
     195    var methods = $.extend({}, $.validator.methods); 
     196    var messages = $.extend({}, $.validator.messages); 
    503197    $.validator.addMethod("foo", function() { return false; }); 
    504198    $.validator.addMethod("bar", function() { return false; }); 
     
    515209    equals( "Please!", $("#testForm4 label.error[@for=f1]").text() ); 
    516210    equals( "Wohoo!", $("#testForm4 label.error[@for=f2]").text() ); 
     211     
     212    $.validator.methods = methods; 
     213    $.validator.messages = messages; 
    517214}); 
    518215 
     
    570267test("rules() - external - complete form", function() { 
    571268    expect(1); 
     269     
     270    var methods = $.extend({}, $.validator.methods); 
     271    var messages = $.extend({}, $.validator.messages); 
     272     
    572273    $.validator.addMethod("verifyTest", function() { 
    573274        ok( true, "method executed" ); 
     
    581282    }); 
    582283    v.form(); 
     284     
     285    $.validator.methods = methods; 
     286    $.validator.messages = messages; 
    583287}); 
    584288 
     
    736440     
    737441    $("#firstname").val("hix").keyup(); 
     442    $("#testForm1").triggerHandler("keyup", [jQuery.event.fix({ type: "keyup", target: $("#firstname")[0] })]); 
    738443    equals( 1, labelContainer.find("label:visible").length ); 
    739444    equals( "There are 1 errors in your form.", container.html() ); 
     
    760465    ok( !v.findLastActive() ); 
    761466    try { 
    762         var lastInput = $("#testForm1 input:last").focus()[0]; 
     467        $("#testForm1").triggerEvent("focusin", $("#testForm1 input:last")[0]); 
    763468        v.focusInvalid(); 
    764469        equals( lastInput, v.findLastActive() ); 
     
    829534    var counter = 0; 
    830535    function add() { 
    831         var input = $("<input class='{required:true}' name='list" + counter++ + "' />").appendTo("#testForm2"); 
    832         v.refresh(); 
    833         return input; 
     536        return $("<input class='{required:true}' name='list" + counter++ + "' />").appendTo("#testForm2"); 
    834537    } 
    835538    var v = $("#testForm2").validate(); 
     
    841544    errors(3); 
    842545    add(); 
    843     var added = add(); 
    844     v.refresh(added); 
     546    v.refresh(add()); 
    845547    v.form(); 
    846548    errors(4); 
     
    871573    equals("", $("#firstname").val(), "form plugin is included, therefor resetForm must also reset inputs, not only errors"); 
    872574}); 
    873  
     575/* 
    874576test("ajaxSubmit", function() { 
    875577    expect(1); 
     
    889591    //jQuery("#signupForm").submit(function() { return false;}).submit(); 
    890592}); 
    891  
    892 test("option: invalidHandler", function() { 
    893      
    894 }); 
     593*/ 
    895594 
    896595module("misc"); 
     
    1017716        equals(expected, v.size(), message ); 
    1018717    } 
     718    function blur(target) { 
     719        $("#testForm1").triggerEvent("focusout", target[0]); 
     720    } 
    1019721    var e = $("#firstname"); 
    1020722    var v = $("#testForm1").validate(); 
    1021     e.blur(); 
     723    blur(e); 
    1022724    errors(0, "No value yet, required is skipped on blur"); 
    1023725    e.val("h"); 
    1024     e.blur(); 
     726    blur(e); 
    1025727    errors(1, "Required was ignored, but as something was entered, check other rules, minLength isn't met"); 
    1026728    e.val("hh"); 
     
    1029731    v.form(); 
    1030732    errors(2, "Submit checks all rules, both fields invalid"); 
    1031     e.blur(); 
     733    blur(e); 
    1032734    errors(1, "Blurring the field results in emptying the error list first, then checking the invalid field: its still invalid, don't remove the error" ); 
    1033735    e.val("h"); 
    1034     e.blur(); 
     736    blur(e); 
    1035737    errors(1, "Entering a single character fulfills required, but not minLength: 2, still invalid"); 
    1036738    e.val("hh"); 
    1037