I'm facing a very weird problem regarding the dynamical setting of an input value with JQuery.
The initial state of the targeted input is as following:
<input type="text" id="birthdate" name="birthdate" value="" data-alt-value="0000-00-00" autocomplete="off" data-local-value="0000-00-00">
Note: The input fields are generated through the Joomla framework (may be it matters, I don't know).
If I set the value in a regular way:
$('[name="birthdate"]').val("1986-01-21");
I get this result:
<input type="text" id="birthdate" name="birthdate" value="" data-alt-value="1986-01-21" autocomplete="off" data-local-value="1986-01-21">
The value attribute is not set. So I tried this way:
$('[name="birthdate"]').attr('value', "1986-01-21");
which gives the expected result:
<input type="text" id="birthdate" name="birthdate" value="1986-01-21" data-alt-value="1986-01-21" autocomplete="off" data-local-value="1986-01-21">
But for whatever reason the value is empty after the form is submitted. Even stranger, if I give the focus to the birthdate field (by clicking in it) then submit the form, the value is passed correctly.
I would point out that this problem occurs only with input fields dealing with date or datetime values.
Can someone helps me ?