So I created a date input field where the field box displays the date, but as default it displays (mm/dd/yyyy) and I was wondering if you can replace this with the current date...
I've looked at other questions and it didn't really help much. I put this block of code under the <script>
tag. And it still didn't replace the (mm/dd/yyyy) text in the field. How can I do this or if it is possible.
function getTodaysDate() {
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10){
dd='0'+dd
}
if(mm<10){
mm='0'+mm
}
var today = dd+'/'+mm+'/'+yyyy;
document.write(today);
}
<p>
Date: <input type="date" name="currentDate" id="currentDate" value="currentDate();"/>
</p>