Server : LiteSpeed System : Linux premium163.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64 User : infihsqw ( 644) PHP Version : 8.1.29 Disable Function : NONE Directory : /home/infihsqw/public_html/controlPanel/assets/plugins/jquery-validation/src/additional/ |
/* * Lets you say "at least X inputs that match selector Y must be filled." * * The end result is that neither of these inputs: * * <input class="productinfo" name="partnumber"> * <input class="productinfo" name="description"> * * ...will validate unless at least one of them is filled. * * partnumber: {require_from_group: [1,".productinfo"]}, * description: {require_from_group: [1,".productinfo"]} * * options[0]: number of fields that must be filled in the group * options[1]: CSS selector that defines the group of conditionally required fields */ $.validator.addMethod("require_from_group", function(value, element, options) { var $fields = $(options[1], element.form), $fieldsFirst = $fields.eq(0), validator = $fieldsFirst.data("valid_req_grp") ? $fieldsFirst.data("valid_req_grp") : $.extend({}, this), isValid = $fields.filter(function() { return validator.elementValue(this); }).length >= options[0]; // Store the cloned validator for future validation $fieldsFirst.data("valid_req_grp", validator); // If element isn't being validated, run each require_from_group field's validation rules if (!$(element).data("being_validated")) { $fields.data("being_validated", true); $fields.each(function() { validator.element(this); }); $fields.data("being_validated", false); } return isValid; }, $.validator.format("Please fill at least {0} of these fields."));