From 55c6abe7bd85250737ba50e3e1f89cfe244fc730 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 30 Aug 2016 09:54:55 +0100 Subject: [PATCH] [SIGNED-OFF] Bug 14060: Force leading zeros on date Content-Type: text/plain; charset="utf-8" If a date does not contain leading zeros for day and month, the date will be refused. parseDate function considers 1/1/1990 as a valid date, but our perl code does not. We must refuse it. Signed-off-by: Owen Leonard --- koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc index 185a51c..14ec21d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc @@ -11,17 +11,17 @@ var MSG_PLEASE_ENTER_A_VALID_DATE = _("Please enter a valid date (should match % function is_valid_date(date) { var dateformat = dateformat_str = '[% Koha.Preference('dateformat') %]'; if ( dateformat == 'us' ) { + if ( date.search(/\d{2}\/\d{2}\/\d{4}/) == -1 ) return 0; dateformat = 'mm/dd/yy'; - dateformat_str = 'mm/dd/yyyy'; } else if ( dateformat == 'metric' ) { + if ( date.search(/\d{2}\/\d{2}\/\d{4}/) == -1 ) return 0; dateformat = 'dd/mm/yy'; - dateformat_str = 'dd/mm/yyyy'; } else if (dateformat == 'iso' ) { + if ( date.search(/\d{2}-\d{2}-\d{4}/) == -1 ) return 0; dateformat = 'yy-mm-dd'; - dateformat_str = 'yyyy-mm-dd'; } else if ( dateformat == 'dmydot' ) { + if ( date.search(/\d{2}\.\d{2}\.\d{4}/) == -1 ) return 0; dateformat = 'dd.mm.yy'; - dateformat_str = 'dd.mm.yyyy'; } try { $.datepicker.parseDate(dateformat, date); -- 2.1.4