From 25bed9767d74362a369b87b43cf674e36709bc40 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 23 Apr 2013 14:21:13 +0200 Subject: [PATCH] Clear altField in datepicker when visible input is cleared cf. http://beta.woltlab.com/index.php/Thread/104-Geburstag-l%C3%A4sst-sich-nicht-entfernen/ --- wcfsetup/install/files/js/WCF.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index 3e00eb4305..a69acb65e9 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -2210,7 +2210,7 @@ WCF.Date.Picker = { $('input[type=date]:not(.jsDatePicker)').each($.proxy(function(index, input) { var $input = $(input); var $inputName = $input.prop('name'); - var $inputValue = $input.prop('value'); // should be Y-m-d, must be interpretable by Date + var $inputValue = $input.val(); // should be Y-m-d, must be interpretable by Date // update $input $input.prop('type', 'text').addClass('jsDatePicker'); @@ -2232,7 +2232,13 @@ WCF.Date.Picker = { monthNames: WCF.Language.get('__months'), monthNamesShort: WCF.Language.get('__monthsShort'), showOtherMonths: true, - yearRange: ($input.hasClass('birthday') ? '-100:+0' : '1900:2038') + yearRange: ($input.hasClass('birthday') ? '-100:+0' : '1900:2038'), + onClose: function(dateText, datePicker) { + // clear altField when datepicker is cleared + if (dateText == '') { + $(datePicker.settings["altField"]).val(dateText); + } + } }); // format default date -- 2.20.1