I'm working at a checkout page. I need to disable an input (#dreturn) if the previous input (dpick) is empty.
This is my code:
$(document).ready(function(){
var minDate = new Date();
$("#dpick").datepicker({
showAnim: 'drop',
numberOfMonth: 1,
maxDate: 7,
minDate: minDate,
dateFormat: 'yy/mm/dd',
onClose : function(selectedDate){
$('#dreturn').datepicker("option", "minDate", selectedDate);
}});
var minDate = new Date();
$("#dreturn").datepicker({
showAnim: 'drop',
numberOfMonth: 1,
maxDate: 7,
minDate: minDate,
dateFormat: 'yy/mm/dd',
onClose : function(selectedDate){
$('#dreturn').datepicker("option", "minDate", selectedDate);
}});
This is my datapicker but this isn't helping me.
$('#dreturn').change(function() {
var start = $('#dpick').datepicker('getDate');
var end = $('#dreturn').datepicker('getDate');
if (start<end) {
var days = (end - start)/1000/60/60/24;
$('#days').val(days);
}
else {
alert ("Please chech again your dates!");
$('#dpick').val("");
$('#dreturn').val("");
$('#days').val("");
}
});
I've tried this but isn't working.
if (!'dpick').val() {
document.getElementById("dreturn").disabled = true;
}
});