};
ns.validate = function($e) {
+ var $e_annotate;
+ if ($e.data('ckeditorInstance')) {
+ $e_annotate = $($e.data('ckeditorInstance').editable().$);
+ if ($e.data('title'))
+ $e_annotate.data('title', $e.data('title'));
+ }
var tests = $e.data('validate').split(/ +/);
for (var test_idx in tests) {
continue;
if (ns.checks[test]) {
- if (!ns.checks[test]($e))
+ if (!ns.checks[test]($e, $e_annotate))
return false;
} else {
var error = "kivi.validate_form: unknown test '" + test + "' for element ID '" + $e.prop('id') + "'";
}
ns.checks = {
- required: function($e) {
+ required: function($e, $e_annotate) {
+ $e_annotate = $e_annotate || $e;
+
if ($e.val() === '') {
- ns.annotate($e, kivi.t8("This field must not be empty."));
+ ns.annotate($e_annotate, kivi.t8("This field must not be empty."));
return false;
} else {
- ns.annotate($e);
+ ns.annotate($e_annotate);
return true;
}
},
- number: function($e) {
+ number: function($e, $e_annotate) {
+ $e_annotate = $e_annotate || $e;
+
var number_string = $e.val();
var parsed_number = kivi.parse_amount(number_string);
if (parsed_number === null) {
$e.val('');
- ns.annotate($e);
+ ns.annotate($e_annotate);
return true;
} else
if (parsed_number === undefined) {
- ns.annotate($e, kivi.t8('Wrong number format (#1)', [ kivi.myconfig.numberformat ]));
+ ns.annotate($e_annotate, kivi.t8('Wrong number format (#1)', [ kivi.myconfig.numberformat ]));
return false;
} else
{
var formatted_number = kivi.format_amount(parsed_number);
if (formatted_number != number_string)
$e.val(formatted_number);
- ns.annotate($e);
+ ns.annotate($e_annotate);
return true;
}
},
- date: function($e) {
+ date: function($e, $e_annotate) {
+ $e_annotate = $e_annotate || $e;
+
var date_string = $e.val();
var parsed_date = kivi.parse_date(date_string);
if (parsed_date === null) {
$e.val('');
- ns.annotate($e);
+ ns.annotate($e_annotate);
return true;
} else
if (parsed_date === undefined) {
- ns.annotate($e, kivi.t8('Wrong date format (#1)', [ kivi.myconfig.dateformat ]));
+ ns.annotate($e_annotate, kivi.t8('Wrong date format (#1)', [ kivi.myconfig.dateformat ]));
return false;
} else
{
var formatted_date = kivi.format_date(parsed_date);
if (formatted_date != date_string)
$e.val(formatted_date);
- ns.annotate($e);
+ ns.annotate($e_annotate);
return true;
}
},
- time: function($e) {
+ time: function($e, $e_annotate) {
+ $e_annotate = $e_annotate || $e;
+
var time_string = $e.val();
var parsed_time = kivi.parse_time(time_string);
if (parsed_time === null) {
$e.val('');
- ns.annotate($e);
+ ns.annotate($e_annotate);
return true;
} else
if (parsed_time === undefined) {
- ns.annotate($e, kivi.t8('Wrong time format (#1)', [ kivi.myconfig.timeformat ]));
+ ns.annotate($e_annotate, kivi.t8('Wrong time format (#1)', [ kivi.myconfig.timeformat ]));
return false;
} else
{
var formatted_time = kivi.format_time(parsed_time);
if (formatted_time != time_string)
$e.val(formatted_time);
- ns.annotate($e);
+ ns.annotate($e_annotate);
return true;
}
}