jophab jophab - 3 months ago 15
HTML Question

Chrome and Opera showing placeholder in date input even when value is set

I have an input type date in my from. If the value is already given by the user, it will be fetched from database. In firefox this works fine. But in Chrome and Opera the place holder 'dd-mm-yyyy' is shown. What is the problem?

<div class="form-group">
<label>Date of Birth</label>
<input value="<?php get("student","dob"); ?>" name="doj" type="date" class="form-control" placeholder="DD - MM - YYYY">
</div>


The resultant code in browser:

<div class="form-group">
<label>Date of Birth</label>
<input value="01-01-1970" name="dob" class="form-control" type="date">
</div>


But still place holder is shown instead of value. This is working in firefox.

Answer

<div class="form-group">
    <label>Date of Birth</label>
    <input value="2016-07-04" name="dob" class="form-control" type="date">
</div>

please refer to the value property here, your format is wrong

Comments