Bill
Bill

Reputation: 19238

input type="datetime-local" valueAsDate return null

<input name="datetime" type="datetime-local" />

The above input only works with valueAsNumber, when I switch to valueAsDate it returns null.

I guess it's because failed to convert into Date?

Upvotes: 2

Views: 2012

Answers (1)

Sydney Y
Sydney Y

Reputation: 3152

Your input is not a date, it is a datetime

You are correct, it failed to convert into Date.

You could do this instead:

var datevalue = new Date(myinput.value);

Upvotes: 2

Related Questions