Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
drupal.org
clientside_validation
Commits
5baf6968
Commit
5baf6968
authored
Jan 03, 2013
by
Jelle Sebreghts
Browse files
not_equal for fapi
parent
9dfc9d4b
Changes
2
Hide whitespace changes
Inline
Side-by-side
clientside_validation.module
View file @
5baf6968
...
...
@@ -923,15 +923,29 @@ function _clientside_validation_set_plain_text($name, $title, $allowed_tags, &$j
/**
* Set validation rule for required fields that must equal a value from an other field.
*/
function
_clientside_validation_set_equal
(
$name
,
$title
,
$value
,
&
$js_rules
)
{
function
_clientside_validation_set_equal
(
$name
,
$title
,
$value
,
&
$js_rules
,
$message
=
''
,
$webform
=
FALSE
)
{
$title
=
_clientside_validation_set_title
(
$title
);
$js_rules
[
$name
][
'equalTo'
]
=
':input[name=\'submitted['
.
$value
[
'form_key'
]
.
']\']'
;
$variables
=
array
(
'message'
=>
'!title field has to be equal to !firstone.'
,
'placeholders'
=>
array
(
'!title'
=>
$title
,
'!firstone'
=>
$value
[
'name'
]),
'error_type'
=>
'equalto'
,
'element_name'
=>
$name
,
);
if
(
$webform
)
{
$js_rules
[
$name
][
'equalTo'
]
=
':input[name=\'submitted['
.
$value
[
'form_key'
]
.
']\']'
;
}
else
{
$js_rules
[
$name
][
'equalTo'
]
=
':input[name=\''
.
$value
[
'element_name'
]
.
'\']'
;
}
if
(
empty
(
$message
))
{
$variables
=
array
(
'message'
=>
'!title field has to be equal to !firstone.'
,
'placeholders'
=>
array
(
'!title'
=>
$title
,
'!firstone'
=>
$value
[
'name'
]),
'error_type'
=>
'equalto'
,
'element_name'
=>
$name
,
);
}
else
{
$variables
=
array
(
'message'
=>
$message
,
'error_type'
=>
'plaintext'
,
'element_name'
=>
$name
,
);
}
$js_rules
[
$name
][
'messages'
][
'equalTo'
]
=
theme
(
'clientside_error'
,
$variables
);
}
...
...
clientside_validation_webform/clientside_validation_webform.module
View file @
5baf6968
...
...
@@ -218,7 +218,7 @@ function clientside_validation_webform_add_webform_validation($form_id, &$form,
$firstone
=
array_shift
(
$others
);
$firstone
[
'form_key'
]
=
implode
(
']['
,
webform_component_parent_keys
(
node_load
(
$firstone
[
'nid'
]),
$firstone
));
foreach
(
$others
as
$component
)
{
_clientside_validation_set_equal
(
$component
[
'element_name'
],
$component
[
'element_title'
],
$firstone
,
$js_rules
);
_clientside_validation_set_equal
(
$component
[
'element_name'
],
$component
[
'element_title'
],
$firstone
,
$js_rules
,
''
,
TRUE
);
}
break
;
case
'unique'
:
...
...
Write
Preview
Supports
Markdown
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