2

I have an input with type "date":

<input type="date" value="2016-08-16"/>

When I load the page I can see that specified date is selected. enter image description here

However, if I try to select another date - 11 August 2016, for example - value in the input is not updating and is always 08/16/2016.

I'm testing page in Chrome Version 53.0.2785.116 (64-bit). Do I miss something in element declaration?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Tamara
  • 2,910
  • 6
  • 44
  • 73
  • This might be informative: [Datepicker does not update input field upon selecting date](http://stackoverflow.com/questions/27461193/jquery-datepicker-does-not-update-input-field-upon-selecting-date) – showdev Sep 26 '16 at 23:57
  • Hi @showdev Thank you for the link. I understand that "value" attribute of the input will not be updated if you check it with web-inspector. However I expect that value displayed on the page - and visible to user - should have value that you just selected. – Tamara Sep 27 '16 at 20:07
  • Ok, I see. Unfortunately, I'm not able to reproduce that issue. – showdev Sep 27 '16 at 20:15
  • *if I try to select another date* -- How? How are you selecting another date? Programmatically, or through the control? – Tim Roberts Aug 10 '23 at 00:01

1 Answers1

-1

You need to handle input value with a variable.

let inputDate = "2021-06-18";

const handleChange = (event) => {
  inputDate = event.target.value;
}
<input type="date" value=inputDate onChange={handleChange} />