I have done a workaround for you to achieve what you have said
<input type="text" value="Enter date!" id="dte" class="datepicker">
<br/>
<br/>
<input type="text" id="time" value=" time!" >
$(".datepicker").datepicker({dateFormat: "yy-mm-dd"});
$("input.datepicker").on("keyup change", function(){
var today = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()).getTime();
var d = new Date();
var month = d.getMonth()+1;
var day = d.getDate();
var output = d.getFullYear() + '-' +
((''+month).length<2 ? '0' : '') + month + '-' +
((''+day).length<2 ? '0' : '') + day;
var selected = $("#dte").val();
if(selected==output)
{
var today = new Date();
today.setHours(today.getHours()+1);
var dt = new Date();
var time = dt.getHours() +1;
var ee=time+":"+ dt.getMinutes() + ":" + dt.getSeconds();
$("#time").val(ee);
}
else
{
var dt = new Date();
var time = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
$("#time").val(time);
}
});
Here is a working fiddle:https://jsfiddle.net/athulmathew/06y8w72x/35/
Note: This is just a workaround you should use it as per your needs!
0
solved time and date validation in javascript [closed]