34 |
34 |
}
|
35 |
35 |
|
36 |
36 |
function check_right_number_format(input_name) {
|
37 |
|
if(decpoint && thpoint && thpoint == decpoint) {
|
38 |
|
return show_alert_and_focus(input_name, wrongNumberFormat);
|
39 |
|
}
|
40 |
37 |
var test_val = input_name.value;
|
41 |
38 |
if(thpoint && thpoint == ','){
|
42 |
39 |
test_val = test_val.replace(/,/g, '');
|
... | ... | |
52 |
49 |
}
|
53 |
50 |
var forbidden = test_val.match(/[^\s\d\(\)\-\+\*\/\.]/g);
|
54 |
51 |
if (forbidden && forbidden.length > 0 ){
|
55 |
|
return show_alert_and_focus(input_name, wrongNumberFormat);
|
|
52 |
return annotate(input_name, kivi.t8('wrongformat'), kivi.myconfig.numberformat);
|
56 |
53 |
}
|
57 |
54 |
|
58 |
55 |
try{
|
59 |
56 |
eval(test_val);
|
60 |
57 |
}catch(err){
|
61 |
|
return show_alert_and_focus(input_name, wrongNumberFormat);
|
|
58 |
return annotate(input_name, kivi.t8('wrongformat'), kivi.myconfig.numberformat);
|
62 |
59 |
}
|
63 |
60 |
|
|
61 |
return annotate(input_name);
|
64 |
62 |
}
|
65 |
63 |
|
66 |
64 |
function check_right_date_format(input_name) {
|
67 |
65 |
if(input_name.value == "") {
|
|
66 |
annotate(input_name);
|
68 |
67 |
return true;
|
69 |
68 |
}
|
70 |
69 |
|
... | ... | |
111 |
110 |
if(!(dateFormat.lastIndexOf("y") == 3) && !matching.test(input_name.value)) {
|
112 |
111 |
matching = new RegExp(dateFormat.replace(/\w/g, '\\d') + '\\d\\d\$', "ig");
|
113 |
112 |
if(!matching.test(input_name.value)) {
|
114 |
|
return show_alert_and_focus(input_name, wrongDateFormat);
|
|
113 |
return annotate(input_name, kivi.t8('Falsches Datumsformat!'), kivi.myconfig.dateformat);
|
115 |
114 |
}
|
116 |
115 |
}
|
117 |
116 |
else {
|
118 |
117 |
if (dateFormat.lastIndexOf("y") == 3 && !matching.test(input_name.value)) {
|
119 |
|
return show_alert_and_focus(input_name, wrongDateFormat);
|
|
118 |
return annotate(input_name, kivi.t8('Falsches Datumsformat!'), kivi.myconfig.dateformat);
|
120 |
119 |
}
|
121 |
120 |
}
|
|
121 |
return annotate(input_name);
|
122 |
122 |
}
|
123 |
123 |
|
124 |
|
function show_alert_and_focus(input_name, errorMessage) {
|
125 |
|
input_name.select();
|
126 |
|
alert(errorMessage + "\n\r\n\r--> " + input_name.value);
|
127 |
|
input_name.focus();
|
128 |
|
return false;
|
|
124 |
function annotate(input_name, error, expected) {
|
|
125 |
var $e = $(input_name);
|
|
126 |
if (error) {
|
|
127 |
$e.addClass('kivi-validator-invalid');
|
|
128 |
var tooltip = error + ' (' + expected + ')';
|
|
129 |
if ($e.hasClass('tooltipstered'))
|
|
130 |
$e.tooltipster('destroy');
|
|
131 |
|
|
132 |
$e.tooltipster({
|
|
133 |
content: tooltip,
|
|
134 |
theme: 'tooltipster-light',
|
|
135 |
});
|
|
136 |
$e.tooltipster('show');
|
|
137 |
} else {
|
|
138 |
$e.removeClass('kivi-validator-invalid');
|
|
139 |
if ($e.hasClass('tooltipstered'))
|
|
140 |
$e.tooltipster('destroy');
|
|
141 |
}
|
129 |
142 |
}
|
130 |
143 |
|
131 |
144 |
function get_input_value(input_name) {
|
js/common.js: show_alert_and_focus auf annotate umgeschrieben