OAuth OK!
This commit is contained in:
parent
494a840f70
commit
567e4a6635
382 changed files with 52478 additions and 7572 deletions
37
testOauthClient/wwwroot/lib/jquery-validation/src/additional/require_from_group.js
vendored
Normal file
37
testOauthClient/wwwroot/lib/jquery-validation/src/additional/require_from_group.js
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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."));
|
||||
Loading…
Add table
Add a link
Reference in a new issue