Commit 5154953a authored by lkmorlan's avatar lkmorlan Committed by Peter Droogmans
Browse files

Issue #1886424 by Liam Morland: Fixed Date validation fails when text is used instead of numbers.

parent 0416e803
......@@ -1146,8 +1146,18 @@
var parts = value.split(param.splitter);
var expectedpartscount = 0;
var day = parseInt(parts[param.daypos], 10);
var month = parseInt(parts[param.monthpos], 10);
if (isNaN(month)) {
if (typeof Drupal.settings.clientside_validation_settings[parts[param.monthpos]] !== undefined) {
month = Drupal.settings.clientside_validation_settings[parts[param.monthpos]];
}
else {
month = new Date(parts[param.monthpos] + " 1, 2000");
month = month.getMonth();
}
month = month - 1;
var year = parseInt(parts[param.yearpos], 10);
var date = new Date();
var result = true;
......@@ -1293,4 +1303,4 @@
}
};
})(jQuery);
\ No newline at end of file
})(jQuery);
......@@ -38,6 +38,14 @@ function clientside_validation_js_alter() {
}
}
}
// Provide conversion table between translated month names, both full and abbreviated, and their number.
foreach (range(1, 12) as $month_number) {
$date = mktime(12, 0, 0, $month_number, 1, 1970);
$clientside_validation_settings['clientside_validation_settings']['months'][t(date('F', $date))] = $month_number;
$clientside_validation_settings['clientside_validation_settings']['months'][t(date('M', $date))] = $month_number;
}
drupal_add_js($clientside_validation_settings, 'setting');
}
......@@ -1555,7 +1563,7 @@ function clientside_validation_library_alter(&$libraries, $module) {
}
$path = drupal_get_path('module', 'clientside_validation');
// Replace jQuery Form plugin.
$libraries['jquery.form']['js']['misc/jquery.form.js']['data'] = $path . '/jquery.form.js';
$libraries['jquery.form']['version'] = '3.09';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment