function addDate(){
    date = new Date();
    var month = date.getMonth()+1;
    var day = date.getDate();
    var year = date.getFullYear();
    
    if (document.getElementById('date').value == ''){
        document.getElementById('date').value = day + '-' + month + '-' + year;
    }
}<body onload="addDate();">
        <input type="date" id="date"/>
</body>it work fine when i change type="text" of input filed ...
but when i change type="date" it does not work..... 
i want to display current date in type of date
thanks
 
    