0

I have a date input control on my web page, and I cannot seem to be able to assign it a value in Chrome. This is my control:

<input type='date' id='dateDate' />

And I am assigning a value to it like this:

$('#dateDate').val('5/16/2018');

This works in IE, but it is not working in Chrome. Does anyone know why? Does Chrome handle date inputs differently now? Do I need to pass in an actual date object?

Below is a quick example. If you run it in IE, both fields are assigned properly. But if you run it Chrome, only the text input is assigned and not the date input.

$('#assignDates').on('click', function(e){
    $('#textDate').val('5/16/2018');
    $('#dateDate').val('5/16/2018');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
input[type=text]: <input type='text' id='textDate' /><br/>
input[type=date]: <input type='date' id='dateDate' /><br/>
<input type='button' id='assignDates' value='Assign Dates' />
Matt Spinks
  • 6,380
  • 3
  • 28
  • 47

0 Answers0