Categories
JavaScript Answers

How to set date in input type date with JavaScript?

Spread the love

To set date in input type date with JavaScript, we set the valueAsDate property.

For instance, we write

document.getElementById("datePicker").valueAsDate = new Date();

to select the date input with getElementById.

And then we set its valueAsDate property to the date value.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *