Is it possible to know if an input type = datetime-local is halfway filled? For example, if only the date or time is filled?
<input type="datetime-local" class="form-control input-lg" id="dueDate"
ng-model="jobDueDate" min="{{currentMin | date:'yyyy-MM-ddTHH:mm'}}"
placeholder="Due Date" >
The element object value of the input tag is empty no matter if it is empty or halfway filled.
var valuedate = document.getElementById('dueDate');
console.log(valuedate.value());
Date.parse returns NaN as well for both cases. Is there a possible solution? I'm using Jquery & AngularJS if those could help. Feel free to post cleaner solutions using other input types (no extra libraries). The aim is for the user to fill both fields out.
EDIT: Field can either be left blank or fully filled. I need to know if it's half filled so I can prompt the user or calculate the required date myself.
One thing the datetime-local input type doesn't provide is a way to set the time zone and/or locale of the date/time control. This was available in the datetime input type, but this type is now obsolete, having been removed from the spec.
The input element with a type attribute whose value is " datetime-local " represents a control for setting the element's value to a string representing a local date and time (with no timezone information).
The difference between the two is that the datetime-local input does not include the time zone. If the time zone is not important to your application, use datetime-local. Some browsers are still trying to catch up to the datetime input type.
You can detect half-filled field by:
document.querySelector('#dueDate').validity.badInput
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With