Answer the question
In order to leave comments, you need to log in
How can I set the date in the format I need in the type="date" field using javascript?
There is a type="date" field
<input class="date" type="date" name="date" placeholder="__.__.____">
today = new Date();
day = today.getDate() < 10 ? '0' + today.getDate() : today.getDate();
month = today.getMonth()+1 < 10 ? '0' + (today.getMonth()+1) : (today.getMonth()+1);
date = day + '.' + month + '.' + today.getFullYear();
$('.date').val(date);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question