From d13d29f623581450d4c8abde7a3a4f8d1864311c Mon Sep 17 00:00:00 2001 From: sparkyx Date: Fri, 29 Jan 2021 12:20:53 +0100 Subject: [PATCH] =?UTF-8?q?New=200001893:=20Date=20remplacement=20auto=20d?= =?UTF-8?q?es=20s=C3=A9parateurs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/js/scripts.js | 10 ++++++++++ include/lib/idate.class.php | 9 ++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/html/js/scripts.js b/html/js/scripts.js index 04cc00b1c..5fce465d8 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -330,6 +330,16 @@ function format_number(obj, p_prec) $(obj).value = value; } + +/** + * Replace slash and minus by dot + * @param p_object + */ +function format_date(p_object) +{ + p_object.value=p_object.value.replace(/\//g,'.'); + p_object.value=p_object.value.replace(/-/g,'.'); +} /** *@brief check if the object is hidden or show and perform the opposite, * show the hidden obj or hide the shown one diff --git a/include/lib/idate.class.php b/include/lib/idate.class.php index 8eab4fdbc..7d9d8a322 100644 --- a/include/lib/idate.class.php +++ b/include/lib/idate.class.php @@ -132,7 +132,7 @@ class IDate extends HtmlInput return $this->display(); if ($this->id=="") $this->id=self::generate_id($this->name); $autofocus=($this->autofocus)?" autofocus ":""; - + $onchange='onchange="format_date(this)"'; $r=sprintf(' - ',$this->name,$this->id,$this->value,$this->placeholder,$this->title,$this->id + ',$this->name,$this->id,$this->value,$this->placeholder,$this->title, + $onchange, + $this->id ); // @see calendar-setup.js $r.=sprintf('