Bug 14060: Improve regex to limit year to 4 integers
01/01/01984 should not be considered as a valid date.
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit eab75d0aa4)
Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
This commit is contained in:
parent
ee073f0086
commit
4f5d1faef5
|
|
@ -14,16 +14,16 @@ 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;
|
||||
if ( date.search(/^\d{2}\/\d{2}\/\d{4}($|\s)/) == -1 ) return 0;
|
||||
dateformat = 'mm/dd/yy';
|
||||
} else if ( dateformat == 'metric' ) {
|
||||
if ( date.search(/\d{2}\/\d{2}\/\d{4}/) == -1 ) return 0;
|
||||
if ( date.search(/^\d{2}\/\d{2}\/\d{4}($|\s)/) == -1 ) return 0;
|
||||
dateformat = 'dd/mm/yy';
|
||||
} else if (dateformat == 'iso' ) {
|
||||
if ( date.search(/\d{2}-\d{2}-\d{4}/) == -1 ) return 0;
|
||||
if ( date.search(/^\d{2}-\d{2}-\d{4}($|\s)/) == -1 ) return 0;
|
||||
dateformat = 'yy-mm-dd';
|
||||
} else if ( dateformat == 'dmydot' ) {
|
||||
if ( date.search(/\d{2}\.\d{2}\.\d{4}/) == -1 ) return 0;
|
||||
if ( date.search(/^\d{2}\.\d{2}\.\d{4}($|\s)/) == -1 ) return 0;
|
||||
dateformat = 'dd.mm.yy';
|
||||
}
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue