Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
drupal.org
clientside_validation
Commits
60c899e7
Commit
60c899e7
authored
Feb 03, 2014
by
Peter Droogmans
Browse files
Issue #2180281 by mmtt: Text field with Multiple Options.
parent
f9142abb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
7 deletions
+46
-7
clientside_validation.js
clientside_validation.js
+46
-7
No files found.
clientside_validation.js
View file @
60c899e7
...
@@ -707,17 +707,34 @@
...
@@ -707,17 +707,34 @@
jQuery
.
each
(
self
.
forms
[
formid
].
checkboxrules
,
function
(
r
)
{
jQuery
.
each
(
self
.
forms
[
formid
].
checkboxrules
,
function
(
r
)
{
var
$checkboxes
=
$form
.
find
(
this
.
checkboxgroupminmax
[
2
]).
find
(
'
input[type="checkbox"]
'
);
var
$checkboxes
=
$form
.
find
(
this
.
checkboxgroupminmax
[
2
]).
find
(
'
input[type="checkbox"]
'
);
if
(
$checkboxes
.
length
)
{
if
(
$checkboxes
.
length
)
{
$checkboxes
.
addClass
(
'
require-one
'
);
var
identifier
=
'
require-one-
'
+
this
.
checkboxgroupminmax
[
2
].
substring
(
1
);
var
min
=
this
.
checkboxgroupminmax
[
0
];
var
message
=
this
.
messages
.
checkboxgroupminmax
;
$checkboxes
.
addClass
(
identifier
);
$checkboxes
.
each
(
function
(){
$checkboxes
.
each
(
function
(){
var
$checkbox
=
$
(
this
);
var
rule
=
self
.
forms
[
formid
].
checkboxrules
[
r
];
var
rule
=
self
.
forms
[
formid
].
checkboxrules
[
r
];
if
(
typeof
self
.
validators
[
formid
].
settings
.
messages
[
r
]
===
'
undefined
'
)
{
var
newrule
=
{
self
.
validators
[
formid
].
settings
.
messages
[
r
]
=
{};
require_from_group
:
[
min
,
'
.
'
+
identifier
]
}
}
$
.
extend
(
self
.
validators
[
formid
].
settings
.
messages
[
r
],
rule
.
messages
);
$checkbox
.
rules
(
"
add
"
,
newrule
);
delete
rule
.
messages
;
$checkbox
.
change
(
hideErrordiv
);
$
(
this
).
rules
(
"
add
"
,
rule
);
$
(
this
).
change
(
hideErrordiv
);
if
(
typeof
self
.
validators
[
formid
].
settings
.
messages
[
$checkbox
.
attr
(
'
name
'
)]
===
'
undefined
'
)
{
self
.
validators
[
formid
].
settings
.
messages
[
$checkbox
.
attr
(
'
name
'
)]
=
{};
}
$
.
extend
(
self
.
validators
[
formid
].
settings
.
messages
[
$checkbox
.
attr
(
'
name
'
)],
{
require_from_group
:
message
});
});
});
if
(
typeof
self
.
validators
[
formid
].
settings
.
messages
[
'
.
'
+
identifier
]
===
'
undefined
'
)
{
self
.
validators
[
formid
].
settings
.
messages
[
'
.
'
+
identifier
]
=
{};
}
$
.
extend
(
self
.
validators
[
formid
].
settings
.
messages
[
'
.
'
+
identifier
],
{
require_from_group
:
message
});
console
.
log
(
self
.
validators
[
formid
].
settings
.
messages
);
}
}
});
});
self
.
time
.
stop
(
'
checkboxrules
'
);
self
.
time
.
stop
(
'
checkboxrules
'
);
...
@@ -1335,6 +1352,28 @@
...
@@ -1335,6 +1352,28 @@
}
}
},
jQuery
.
format
(
'
Not a valid EAN number.
'
));
},
jQuery
.
format
(
'
Not a valid EAN number.
'
));
jQuery
.
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
;
},
jQuery
.
validator
.
format
(
"
Please fill at least {0} of these fields.
"
));
/**
/**
* Allow other modules to add more rules.
* Allow other modules to add more rules.
* @event clientsideValidationAddCustomRules
* @event clientsideValidationAddCustomRules
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment