Bug Tracker

Show
Ignore:
Timestamp:
02/01/08 23:30:06 (1 year ago)
Author:
joern.zaefferer
Message:

* Bundled delegeate plugin with validate plugin - its always required anyway
* Added jQuery.validator.autoCreateRanges property, defaults to false, enable to convert min/max to range and minlength/maxlength to rangelength; this basically fixes the issue introduced by automatically creating ranges in 1.2
* Fixed optional-methods to not highlight anything at all if the field is blank, that is, don't trigger success
* Fixed url and email validation to require TLD (actually to require domain label); 1.2 version (TLD is optional) is moved to additionals as url2 and email2
* Fixed dynamic-totals demo in IE6/7 and improved templating, using textarea to store multiline template and string interpolation

Files:
1 modified

Legend:

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

    r4565 r4587  
    77 
    88<link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" /> 
     9 
    910<script src="../lib/jquery.js" type="text/javascript"></script> 
    10 <script type="text/javascript" src="../lib/jquery.delegate.js"></script> 
    1111<script src="../jquery.validate.js" type="text/javascript"></script> 
    1212 
     
    2121     
    2222$().ready(function() { 
    23     var validator = $("#orderform").validate({ 
     23    $("#orderform").validate({ 
    2424        errorPlacement: function(error, element) { 
    2525            error.appendTo( element.parent().parent().next().find("td." + element.parent().attr("class") + "-error") ); 
     
    2727    }); 
    2828     
    29     // TODO improve templating code 
     29    var template = jQuery.format($("#template").val()); 
    3030    function addRow() { 
    31         // add another input with a generated name and remove the id to avoid duplicates 
    32         var items = $("#items").clone().attr("id", "").attr("name", "item-type-" + i).show(); 
    33         $("#template, #template+").clone().attr("id", "").show() 
    34             .find("label").text((i + 1) + ". Item").end() 
    35             .find(".type").append( items ).end() 
    36             .find("input.quantity").attr("name", "item-quantity-" + i).end() 
    37             .appendTo("#orderitems tbody"); 
    38         i++; 
     31        $(template(i++)).appendTo("#orderitems tbody"); 
    3932    } 
    4033     
    41     var i = 0; 
     34    var i = 1; 
    4235    // start with one row 
    4336    addRow(); 
     
    8578<div id="main"> 
    8679 
    87 <table style="display:none"> 
    88     <tr id="template"> 
     80<textarea style="display:none" id="template"> 
     81    <tr> 
    8982        <td> 
    90             <label></label> 
     83            <label>{0}. Item</label> 
    9184        </td> 
    92         <td class='type'></td> 
     85        <td class='type'> 
     86            <select class="required" name="item-type-{0}"> 
     87                <option value="">Select...</option> 
     88                <option value="0">Learning jQuery</option> 
     89                <option value="1">jQuery Reference Guide</option> 
     90                <option value="2">jQuery Cookbook</option> 
     91                <option vlaue="3">jQuery In Action</option> 
     92                <option value="4">jQuery For Designers</option> 
     93            </select> 
     94        </td> 
    9395        <td class='quantity'> 
    94             <input size='4' class="quantity required" min="1" /> 
     96            <input size='4' class="quantity required" min="1" name="item-quantity-{0}" /> 
    9597        </td> 
    9698    </tr> 
     
    101103        <td class='quantity-error'>&nbsp;</td> 
    102104    </tr> 
    103 </table> 
    104  
    105 <select id="items" class="required" style="display:none"> 
    106     <option value="">Select...</option> 
    107     <option value="0">Learning jQuery</option> 
    108     <option value="1">jQuery Reference Guide</option> 
    109     <option value="2">jQuery Cookbook</option> 
    110     <option vlaue="3">jQuery In Action</option> 
    111     <option value="4">jQuery For Designers</option> 
    112 </select> 
     105</textarea> 
    113106 
    114107<form id="orderform" class="cmxform" method="get" action="foo.html">