Revision ccf566c2
Von Thomas Kasulke vor mehr als 17 Jahren hinzugefügt
js/common.js | ||
---|---|---|
1 | 1 |
|
2 | 2 |
function setupPoints(numberformat, wrongFormat) { |
3 |
decpoint = numberformat.substring((numberformat.substring(1, 2).match(/.|,/) ? 5 : 4), (numberformat.substring(1, 2).match(/.|,/) ? 6 : 5));
|
|
4 |
if (numberformat.substring(1, 2).match(/.|,/)) {
|
|
3 |
decpoint = numberformat.substring((numberformat.substring(1, 2).match(/\.|\,/) ? 5 : 4), (numberformat.substring(1, 2).match(/\.|\,/) ? 6 : 5));
|
|
4 |
if (numberformat.substring(1, 2).match(/\.|\,/)) {
|
|
5 | 5 |
thpoint = numberformat.substring(1, 2); |
6 | 6 |
} |
7 | 7 |
else { |
... | ... | |
47 | 47 |
} |
48 | 48 |
|
49 | 49 |
function check_right_number_format(input_name) { |
50 |
var decnumbers = input_name.value.split(decpoint); |
|
51 | 50 |
if(thpoint) { |
52 |
var thnumbers = input_name.value.split(thpoint);
|
|
53 |
if(thnumbers[thnumbers.length-1].match(/.+decpoint$/g)) {
|
|
54 |
thnumbers[thnumbers.length-1] = thnumbers[thnumbers.length-1].substring(thnumbers[thnumbers.length-1].length-1);
|
|
51 |
if(thpoint == ','){
|
|
52 |
var thnumbers = input_name.value.split(',');
|
|
53 |
thnumbers[thnumbers.length-1] = thnumbers[thnumbers.length-1].substring((thnumbers[thnumbers.length-1].lastIndexOf(".") !== -1 ? thnumbers[thnumbers.length-1].lastIndexOf(".") : thnumbers[thnumbers.length-1].length), 0);
|
|
55 | 54 |
} |
56 |
if(thnumbers[thnumbers.length-1].match(/.+decpoint\d$/g)) { |
|
57 |
thnumbers[thnumbers.length-1] = thnumbers[thnumbers.length-1].substring(thnumbers[thnumbers.length-1].length-2); |
|
58 |
} |
|
59 |
if(thnumbers[thnumbers.length-1].match(/.+decpoint\d\d$/g)) { |
|
60 |
thnumbers[thnumbers.length-1] = thnumbers[thnumbers.length-1].substring(thnumbers[thnumbers.length-1].length-3); |
|
61 |
} |
|
62 |
for(var i = 1; i < thnumbers.length; i++) { |
|
63 |
if(!thnumbers[i].match(/\d\d\d/g)) { |
|
64 |
return show_alert_and_focus(input_name, wrongNumberFormat); |
|
65 |
} |
|
66 |
if(thnumbers[i].match(/.*decpoint.*|.*thpoint.*/g)) { |
|
67 |
return show_alert_and_focus(input_name, wrongNumberFormat); |
|
68 |
} |
|
55 |
else{ |
|
56 |
var thnumbers = input_name.value.split('.'); |
|
57 |
thnumbers[thnumbers.length-1] = thnumbers[thnumbers.length-1].substring((thnumbers[thnumbers.length-1].lastIndexOf(",") !== -1 ? thnumbers[thnumbers.length-1].lastIndexOf(",") : thnumbers[thnumbers.length-1].length), 0); |
|
69 | 58 |
} |
70 |
if(decnumbers.length > 2 || (decnumbers.length > 1 ? (decnumbers[1].length > 2) : false)) { |
|
71 |
return show_alert_and_focus(input_name, wrongNumberFormat); |
|
59 |
|
|
60 |
for(var i = 1; i < thnumbers.length; i++) { |
|
61 |
if(thnumbers[i].length !== 3) { |
|
62 |
return show_alert_and_focus(input_name, wrongNumberFormat+thnumbers); |
|
63 |
} |
|
64 |
} |
|
65 |
} |
|
66 |
if(decpoint == ',') { |
|
67 |
var decnumbers = input_name.value.split(','); |
|
68 |
} |
|
69 |
else { |
|
70 |
var decnumbers = input_name.value.split('.'); |
|
71 |
} |
|
72 |
if(decnumbers.length == 2) { |
|
73 |
if(decnumbers[1].length > 2) { |
|
74 |
return show_alert_and_focus(input_name, wrongNumberFormat + decnumbers); |
|
72 | 75 |
} |
73 | 76 |
} |
74 | 77 |
else { |
75 |
if(decnumbers.length > 1 || decnumbers[0].length > 2) {
|
|
78 |
if(decnumbers.length > 1 || decnumbers.length == 0) {
|
|
76 | 79 |
return show_alert_and_focus(input_name, wrongNumberFormat); |
77 | 80 |
} |
81 |
if(!thpoint) { |
|
82 |
if(decnumbers[0].match(/\D/)) { |
|
83 |
return show_alert_and_focus(input_name, wrongNumberFormat); |
|
84 |
} |
|
85 |
} |
|
78 | 86 |
} |
79 | 87 |
} |
80 | 88 |
|
... | ... | |
125 | 133 |
|
126 | 134 |
function show_alert_and_focus(input_name, errorMessage) { |
127 | 135 |
input_name.select(); |
128 |
alert(errorMessage + "\n\r\n\r--> " + input_name.value); |
|
136 |
alert(errorMessage + "\n\r\n\r--> " + input_name.value); // + "\ndecpoint: " + decpoint + "\nthpoint: " + thpoint
|
|
129 | 137 |
input_name.focus(); |
130 | 138 |
return false; |
131 | 139 |
} |
Auch abrufbar als: Unified diff
Bug 644 fixed (Überprüfung des Datumsformat schlug fehl.)