HTML5 input type time setting values not working

2019-01-23 16:44发布

问题:

I have a form with input type time. I am trying to set values. But it is not showing. Here is my code.

<input type="time" name="exit" id="teacher-entry-exit-form-exit-input" class="form-control" value="08:56 AM" required="">

What am I doing wrong?

回答1:

It's based on 24-hour time, therefore use value="08:56" for AM and value="20:56" for PM.

Example Here

<input type="time" value="08:56">

See: http://www.w3.org/TR/html-markup/input.time.html