From db3df548b6a6385ea17d2db49f49f8d4c9f2969f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 30 Aug 2016 09:54:55 +0100 Subject: [PATCH] Bug 14060: Force leading zeros on date 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 Signed-off-by: Nick Clemens Signed-off-by: Kyle M Hall --- 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 185a51c98a..14ec21d222 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.39.5