View | Details | Raw Unified | Return to bug 14060
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc (-5 / +16 lines)
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
//]]>
(-)a/koha-tmpl/intranet-tmpl/prog/en/js/pages/circulation.js (+4 lines)
Lines 37-42 $(document).ready(function() { Link Here
37
        minDate: 1, // require that renewal date is after today
37
        minDate: 1, // require that renewal date is after today
38
        hour: 23,
38
        hour: 23,
39
        minute: 59
39
        minute: 59
40
    }).on("change", function(e) {
41
        if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
40
    });
42
    });
41
    $("#duedatespec").datetimepicker({
43
    $("#duedatespec").datetimepicker({
42
        onClose: function(dateText, inst) {
44
        onClose: function(dateText, inst) {
Lines 46-51 $(document).ready(function() { Link Here
46
        },
48
        },
47
        hour: 23,
49
        hour: 23,
48
        minute: 59
50
        minute: 59
51
    }).on("change", function(e, value) {
52
        if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
49
    });
53
    });
50
    $("#export_submit").on("click",function(){
54
    $("#export_submit").on("click",function(){
51
        var output_format = $("#output_format").val();
55
        var output_format = $("#output_format").val();
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (+2 lines)
Lines 75-80 function toggle_onsite_checkout(){ Link Here
75
            },
75
            },
76
            hour: 23,
76
            hour: 23,
77
            minute: 59
77
            minute: 59
78
        }).on("change", function(e, value) {
79
            if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
78
        });
80
        });
79
    }
81
    }
80
}
82
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt (+2 lines)
Lines 560-565 $(document).ready(function () { Link Here
560
        },
560
        },
561
        hour: 23,
561
        hour: 23,
562
        minute: 59
562
        minute: 59
563
    }).on("change", function(e, value) {
564
        if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
563
    });
565
    });
564
    $('#mainform').submit(function (event) {
566
    $('#mainform').submit(function (event) {
565
        event.preventDefault();
567
        event.preventDefault();
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (+2 lines)
Lines 34-39 $(document).ready(function () { Link Here
34
        hour: 23,
34
        hour: 23,
35
        minute: 59,
35
        minute: 59,
36
        maxDate: 0
36
        maxDate: 0
37
    }).on("change", function(e, value) {
38
        if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
37
    });
39
    });
38
    $("#return_date_override").on("blur", function() {
40
    $("#return_date_override").on("blur", function() {
39
            check_valid_return_date();
41
            check_valid_return_date();
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-1 / +2 lines)
Lines 87-92 $(document).ready(function() { Link Here
87
            validate_date(dateText, inst);
87
            validate_date(dateText, inst);
88
        },
88
        },
89
        minDate: 1, // require that hold suspended until date is after today
89
        minDate: 1, // require that hold suspended until date is after today
90
    }).on("change", function(e, value) {
91
        if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
90
    });
92
    });
91
93
92
 });
94
 });
93
- 

Return to bug 14060