Lines 8-16
var sentmsg = 0;
Link Here
|
8 |
if (debug > 1) {alert("dateformat: " + dformat + "\ndebug is on (level " + debug + ")");} |
8 |
if (debug > 1) {alert("dateformat: " + dformat + "\ndebug is on (level " + debug + ")");} |
9 |
var MSG_PLEASE_ENTER_A_VALID_DATE = _("Please enter a valid date (should match %s)."); |
9 |
var MSG_PLEASE_ENTER_A_VALID_DATE = _("Please enter a valid date (should match %s)."); |
10 |
|
10 |
|
11 |
function validate_date (dateText, inst) { |
11 |
function is_valid_date(date) { |
12 |
var dateformat = '[% Koha.Preference('dateformat') %]'; |
12 |
var dateformat = dateformat_str = '[% Koha.Preference('dateformat') %]'; |
13 |
var dateformat_str = dateformat |
|
|
14 |
if ( dateformat == 'us' ) { |
13 |
if ( dateformat == 'us' ) { |
15 |
dateformat = 'mm/dd/yy'; |
14 |
dateformat = 'mm/dd/yy'; |
16 |
dateformat_str = 'mm/dd/yyyy'; |
15 |
dateformat_str = 'mm/dd/yyyy'; |
Lines 22-32
function validate_date (dateText, inst) {
Link Here
|
22 |
dateformat_str = 'yyyy-mm-dd'; |
21 |
dateformat_str = 'yyyy-mm-dd'; |
23 |
} |
22 |
} |
24 |
try { |
23 |
try { |
25 |
$.datepicker.parseDate(dateformat, dateText); |
24 |
$.datepicker.parseDate(dateformat, date); |
26 |
} catch (e) { |
25 |
} catch (e) { |
|
|
26 |
return 0; |
27 |
}; |
28 |
return 1; |
29 |
} |
30 |
|
31 |
function validate_date (dateText, inst) { |
32 |
if ( !is_valid_date(dateText) ) { |
33 |
var dateformat_str = '[% Koha.Preference('dateformat') %]'; |
27 |
alert(MSG_PLEASE_ENTER_A_VALID_DATE.format(dateformat_str)); |
34 |
alert(MSG_PLEASE_ENTER_A_VALID_DATE.format(dateformat_str)); |
28 |
$('#'+inst.id).val(''); |
35 |
$('#'+inst.id).val(''); |
29 |
}; |
36 |
} |
30 |
} |
37 |
} |
31 |
|
38 |
|
32 |
function Date_from_syspref(dstring) { |
39 |
function Date_from_syspref(dstring) { |
Lines 115-120
$.datepicker.setDefaults({
Link Here
|
115 |
onClose: function(dateText, inst) { |
122 |
onClose: function(dateText, inst) { |
116 |
validate_date(dateText, inst); |
123 |
validate_date(dateText, inst); |
117 |
}, |
124 |
}, |
|
|
125 |
}).on("change", function(e, value) { |
126 |
if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");} |
118 |
}); |
127 |
}); |
119 |
// http://jqueryui.com/demos/datepicker/#date-range |
128 |
// http://jqueryui.com/demos/datepicker/#date-range |
120 |
var dates = $( ".datepickerfrom, .datepickerto" ).datepicker({ |
129 |
var dates = $( ".datepickerfrom, .datepickerto" ).datepicker({ |
Lines 132-137
$.datepicker.setDefaults({
Link Here
|
132 |
onClose: function(dateText, inst) { |
141 |
onClose: function(dateText, inst) { |
133 |
validate_date(dateText, inst); |
142 |
validate_date(dateText, inst); |
134 |
}, |
143 |
}, |
|
|
144 |
}).on("change", function(e, value) { |
145 |
if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");} |
135 |
}); |
146 |
}); |
136 |
}); |
147 |
}); |
137 |
//]]> |
148 |
//]]> |