diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index aa6ce97567b..2a23cfeae12 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -7777,7 +7777,7 @@ class Form
$retstring .= 'trans("FormatDateShortJavaInput")) . '\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
+ $retstring .= ' onChange="dpChangeDay(\'' . dol_escape_js($prefix) . '\',\'' . dol_escape_js($usecalendar == 'html' ? 'yyyy-mm-dd' : $langs->trans("FormatDateShortJavaInput")) . '\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
$retstring .= ' autocomplete="off">';
// Icon calendar
diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php
index 48f765112a1..75b6d57667f 100644
--- a/htdocs/core/js/lib_head.js.php
+++ b/htdocs/core/js/lib_head.js.php
@@ -243,15 +243,17 @@ function getObjectFromID(id){
// Called after the selection or typing of a date to save details into detailed fields
function dpChangeDay(dateFieldID, format)
{
- console.log("Call dpChangeDay, we save date into detailed fields from format = "+format);
+ console.log("Call dpChangeDay, we save date from field "+dateFieldID+" into detailed fields from format = "+format);
var thefield = getObjectFromID(dateFieldID);
var thefieldday = getObjectFromID(dateFieldID+"day");
var thefieldmonth = getObjectFromID(dateFieldID+"month");
var thefieldyear = getObjectFromID(dateFieldID+"year");
+ console.log("string date value is " + thefield.value);
+
var date = getDateFromFormat(thefield.value, format);
- //console.log(date);
+
if (date)
{
thefieldday.value = date.getDate();