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
a9a0479e
Commit
a9a0479e
authored
May 03, 2012
by
Jelle Sebreghts
Browse files
Issue #1535756 by pianomansam: Added Support Field Validation 2.x.
parent
16bf0831
Changes
4
Hide whitespace changes
Inline
Side-by-side
clientside_validation.admin.inc
View file @
a9a0479e
...
...
@@ -92,6 +92,17 @@ function clientside_validation_admin_settings() {
'#default_value'
=>
variable_get
(
'clientside_validation_validate_onkeyup'
,
1
),
);
$form
[
'clientside_validation_validate_options'
][
'clientside_validation_show_messages'
]
=
array
(
'#type'
=>
'radios'
,
'#options'
=>
array
(
'0'
=>
t
(
'Show all error messages'
),
'1'
=>
t
(
'Show only first error message'
),
'2'
=>
t
(
'Show only last error message'
),
),
'#title'
=>
t
(
'Show these error messages on validation'
),
'#default_value'
=>
variable_get
(
'clientside_validation_show_messages'
,
0
),
);
//Error message settings
$form
[
'clientside_validation_error'
]
=
array
(
'#type'
=>
'fieldset'
,
...
...
clientside_validation.js
View file @
a9a0479e
...
...
@@ -343,6 +343,38 @@
if
(
!
Boolean
(
parseInt
(
self
.
data
.
general
.
validateOnKeyUp
)))
{
validate_options
.
onkeyup
=
false
;
}
if
(
parseInt
(
self
.
data
.
general
.
showMessages
)
>
0
)
{
var
showMessages
=
parseInt
(
self
.
data
.
general
.
showMessages
);
// Show only first message
if
(
showMessages
===
1
)
{
validate_options
.
showErrors
=
function
()
{
for
(
var
i
=
0
;
this
.
errorList
[
i
]
&&
i
<
1
;
i
++
)
{
var
error
=
this
.
errorList
[
i
];
this
.
settings
.
highlight
&&
this
.
settings
.
highlight
.
call
(
this
,
error
.
element
,
this
.
settings
.
errorClass
,
this
.
settings
.
validClass
);
this
.
showLabel
(
error
.
element
,
error
.
message
);
}
if
(
this
.
errorList
.
length
)
{
this
.
toShow
=
this
.
toShow
.
add
(
this
.
containers
);
}
if
(
this
.
settings
.
success
)
{
for
(
var
i
=
0
;
this
.
successList
[
i
];
i
++
)
{
this
.
showLabel
(
this
.
successList
[
i
]
);
}
}
if
(
this
.
settings
.
unhighlight
)
{
for
(
var
i
=
0
,
elements
=
this
.
validElements
();
elements
[
i
];
i
++
)
{
this
.
settings
.
unhighlight
.
call
(
this
,
elements
[
i
],
this
.
settings
.
errorClass
,
this
.
settings
.
validClass
);
}
}
this
.
toHide
=
this
.
toHide
.
not
(
this
.
toShow
);
this
.
hideErrors
();
this
.
addWrapper
(
this
.
toShow
).
show
();
}
}
else
if
(
showMessages
===
2
)
{
}
}
self
.
validators
[
f
]
=
$
(
'
#
'
+
f
).
validate
(
validate_options
);
//Disable HTML5 validation
...
...
clientside_validation.module
View file @
a9a0479e
...
...
@@ -304,6 +304,7 @@ function _clientside_validation_add_general_settings(&$settings, $form_id) {
"validateOnKeyUp"
=>
variable_get
(
'clientside_validation_validate_onkeyup'
,
1
),
"validateOnSubmit"
=>
variable_get
(
'clientside_validation_validate_onsubmit'
,
1
),
"errorElement"
=>
variable_get
(
'clientside_validation_error_element'
,
'label'
),
"showMessages"
=>
variable_get
(
'clientside_validation_show_messages'
,
0
),
);
}
...
...
clientside_validation_field_validation/clientside_validation_field_validation.module
View file @
a9a0479e
...
...
@@ -100,8 +100,8 @@ function clientside_validation_field_validation_regular($form_id, $element, $rul
// Field Validation 2.x
case
'field_validation_length_validator'
:
$message
=
''
;
$rule
[
'settings'
][
'min'
]
=
isset
(
$rule
[
'settings'
][
'min'
])
?
''
:
$rule
[
'settings'
][
'min'
];
$rule
[
'settings'
][
'max'
]
=
isset
(
$rule
[
'settings'
][
'max'
])
?
''
:
$rule
[
'settings'
][
'max'
];
$rule
[
'settings'
][
'min'
]
=
isset
(
$rule
[
'settings'
][
'min'
])
?
$rule
[
'settings'
][
'min'
]
:
''
;
$rule
[
'settings'
][
'max'
]
=
isset
(
$rule
[
'settings'
][
'max'
])
?
$rule
[
'settings'
][
'max'
]
:
''
;
if
(
isset
(
$rule
[
'error_message'
]))
{
$message
=
$rule
[
'error_message'
];
}
...
...
@@ -128,8 +128,8 @@ function clientside_validation_field_validation_regular($form_id, $element, $rul
// Field Validation 2.x
case
'field_validation_words_validator'
:
$message
=
''
;
$rule
[
'settings'
][
'min'
]
=
isset
(
$rule
[
'settings'
][
'min'
])
?
''
:
$rule
[
'settings'
][
'min'
];
$rule
[
'settings'
][
'max'
]
=
isset
(
$rule
[
'settings'
][
'max'
])
?
''
:
$rule
[
'settings'
][
'max'
];
$rule
[
'settings'
][
'min'
]
=
isset
(
$rule
[
'settings'
][
'min'
])
?
$rule
[
'settings'
][
'min'
]
:
''
;
$rule
[
'settings'
][
'max'
]
=
isset
(
$rule
[
'settings'
][
'max'
])
?
$rule
[
'settings'
][
'max'
]
:
''
;
if
(
isset
(
$rule
[
'error_message'
]))
{
$message
=
$rule
[
'error_message'
];
}
...
...
@@ -226,8 +226,8 @@ function clientside_validation_field_validation_regular($form_id, $element, $rul
break
;
case
'field_validation_number_of_selections_validator'
:
$message
=
''
;
$rule
[
'settings'
][
'min'
]
=
isset
(
$rule
[
'settings'
][
'min'
])
?
''
:
$rule
[
'settings'
][
'min'
];
$rule
[
'settings'
][
'max'
]
=
isset
(
$rule
[
'settings'
][
'max'
])
?
''
:
$rule
[
'settings'
][
'max'
];
$rule
[
'settings'
][
'min'
]
=
isset
(
$rule
[
'settings'
][
'min'
])
?
$rule
[
'settings'
][
'min'
]
:
''
;
$rule
[
'settings'
][
'max'
]
=
isset
(
$rule
[
'settings'
][
'max'
])
?
$rule
[
'settings'
][
'max'
]
:
''
;
if
(
isset
(
$rule
[
'error_message'
]))
{
$message
=
$rule
[
'error_message'
];
}
...
...
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