HTML5 Forms: Date Input Type - Can it pick up currentDate?

I know it can do things validate on date ranges, but is there a way of getting it to automatically pick up the current system date, if one isn’t selected, without resorting to JavaScript?

PS. As far as I can make out, the answer is no, but who knows

No, I don’t believe it can be done unless you use scripting of some sort. The datepicker associated with the date input (in supporting browsers) will show the current date but you still have to select it to get it entered into the input.

It would seem silly to enter the current date into an input as then the input would seem to be valid but the date may not be what the user wanted as their input.:slight_smile:

1 Like

Is back end scripting an option? That would be easy enough to echo the date into the value attribute.

I guess it depends. How critical is it that a users computer time be used instead of the servers time?

1 Like

I should have expanded a little. I’m looking at a piece of an app that I’d want to enter the current date as a record is initially created (‘this record was created on’ sort of thing), unless there is good reason to override that date. It could end up being a hidden field, in which case Sam’s suggestion of back-end code is likely more viable. For demo purposes though, I wanted to create something that’s entirely built on the front-end, to then hand over the idea to someone, who can actually put it into practice.

I’ve got a part of something sitting on Codepen at the moment - the date thing is just one element of it. I’ll do a separate thread in the JS Forum, and expand on where I’m trying to get to.

Both are on the same domain and should therefore be using the same date/time stamps.Time, though still required is far less critical than the date of record creation.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.