|
33 | 33 |
|
34 | 34 | }());
|
35 | 35 |
|
36 |
| -/* |
37 |
| - * Lets you say "either at least X inputs that match selector Y must be filled, |
38 |
| - * OR they must all be skipped (left blank)." |
39 |
| - * |
40 |
| - * The end result, is that none of these inputs: |
41 |
| - * |
42 |
| - * <input class="productinfo" name="partnumber"> |
43 |
| - * <input class="productinfo" name="description"> |
44 |
| - * <input class="productinfo" name="color"> |
45 |
| - * |
46 |
| - * ...will validate unless either at least two of them are filled, |
47 |
| - * OR none of them are. |
48 |
| - * |
49 |
| - * partnumber: {skip_or_fill_minimum: [2,".productinfo"]}, |
50 |
| - * description: {skip_or_fill_minimum: [2,".productinfo"]}, |
51 |
| - * color: {skip_or_fill_minimum: [2,".productinfo"]} |
52 |
| - * |
53 |
| - */ |
54 |
| -jQuery.validator.addMethod("skip_or_fill_minimum", function(value, element, options) { |
55 |
| - var validator = this, |
56 |
| - numberRequired = options[0], |
57 |
| - selector = options[1]; |
58 |
| - var numberFilled = jQuery(selector, element.form).filter(function() { |
59 |
| - return validator.elementValue(this); |
60 |
| - }).length; |
61 |
| - var valid = numberFilled >= numberRequired || numberFilled === 0; |
62 |
| - |
63 |
| - if(!jQuery(element).data('being_validated')) { |
64 |
| - var fields = $(selector, element.form); |
65 |
| - fields.data('being_validated', true); |
66 |
| - fields.valid(); |
67 |
| - fields.data('being_validated', false); |
68 |
| - } |
69 |
| - return valid; |
70 |
| -}, jQuery.format("Please either skip these fields or fill at least {0} of them.")); |
71 |
| - |
72 | 36 | // Accept a value from a file input based on a required mimetype
|
73 | 37 | jQuery.validator.addMethod("accept", function(value, element, param) {
|
74 | 38 | // Split mime on commas in case we have multiple types we can accept
|
|
0 commit comments