I have the following form on my page:
<input id='startDate' type='datetime-local' step=1 name='startDate'>
I use this code to get the value of the field:
var start = $('#startDate').val();
My problem is that the value of the input field remains undefined until every part of it has been filled out, including hours, minutes, seconds, and AM/PM. I would like to be able to get a value from the form with as little as just the year selected.
How can I go about doing this? I'm happy to zero out the values not filled out, but I can't figure out how to get the part of the datetime-local that the user did fill out.
I know I can do this using the timepicker addon for jQuery UI's datepicker, but I don't really want to go this route - I like the Chrome implementation significantly better.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…