Changeset 4648
- Timestamp:
- 02/05/08 19:26:35 (10 months ago)
- Location:
- trunk/plugins/validate
- Files:
-
- 2 modified
-
changelog.txt (modified) (1 diff)
-
demo/dynamic-totals.html (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/validate/changelog.txt
r4637 r4648 14 14 * Fixed dynamic-totals demo in IE6/7 and improved templating, using textarea to store multiline template and string interpolation 15 15 * Added login form example with "Email password" link that makes the password field optional 16 * Enhanced dynamic-totals demo with an example of a single message for two fields 16 17 17 18 1.2 -
trunk/plugins/validate/demo/dynamic-totals.html
r4587 r4648 19 19 }); 20 20 $.validator.messages.max = jQuery.format("Your totals musn't exceed {0}!"); 21 21 22 $.validator.addMethod("quantity", function(value, element) { 23 return !this.optional(element) && !this.optional($(element).parent().prev().children("select")[0]); 24 }, "Please select both the item and its amount."); 25 22 26 $().ready(function() { 23 27 $("#orderform").validate({ 24 28 errorPlacement: function(error, element) { 25 error.appendTo( element.parent().parent().next().find("td." + element.parent().attr("class") + "-error") ); 29 error.appendTo( element.parent().next() ); 30 }, 31 highlight: function(element, errorClass) { 32 $(element).addClass(errorClass).parent().prev().children("select").addClass(errorClass); 26 33 } 27 34 }); … … 70 77 em.error { color: black; } 71 78 #warning { display: none; } 79 select.error { 80 border: 1px dotted red; 81 } 72 82 </style> 73 83 … … 84 94 </td> 85 95 <td class='type'> 86 <select class="required"name="item-type-{0}">96 <select name="item-type-{0}"> 87 97 <option value="">Select...</option> 88 98 <option value="0">Learning jQuery</option> … … 94 104 </td> 95 105 <td class='quantity'> 96 <input size='4' class="quantity required" min="1" name="item-quantity-{0}" />106 <input size='4' class="quantity" min="1" id="item-quantity-{0}" name="item-quantity-{0}" /> 97 107 </td> 98 </tr> 99 <tr> 100 <!-- keep empty label to avoid height changes when showing error messages --> 101 <td><label style="visibility:hidden"> </label></td> 102 <td class='type-error'> </td> 103 <td class='quantity-error'> </td> 108 <td class='quantity-error'></td> 104 109 </tr> 105 110 </textarea> … … 118 123 <td colspan="2"><label>Totals (max 25)</label></td> 119 124 <td class="totals"><input id="totals" name="totals" value="0" max="25" readonly="readonly" size='4' /></td> 120 </tr>121 <tr>122 <td colspan="2"> </td>123 125 <td class="totals-error"></td> 124 126 </tr>
