0
I am using a datepicker jQuery-UI to generate date in an "input text" field, but I cannot make the date selected in the datepicker set in that input and I do not understand what is wrong.
What is missing in this code so that the input text From
and input text To
have their values changed?
<script src="/javascripts/jquery/jquery-1.12.4.js"></script>
<script src="/javascripts/jquery//jquery-ui.js"></script> <script>
$( function() {
var dtFormat = "dd/mm/yy",
from = $( "#from" )
.datepicker({
//defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 1,
dateFormat: dtFormat,
altFormat: "yy-mm-dd"
})
.on( "change", function() {
to.datepicker( "option", "minDate", getDate( this ) );
}),
to = $( "#to" ).datepicker({
//defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 1,
dateFormat: dtFormat,
altFormat: "yy-mm-dd"
})
.on( "change", function() {
from.datepicker( "option", "maxDate", getDate( this ) );
});
function getDate( element ) {
var date;
try {
date = $.datepicker.parseDate( dtFormat, element.value );
} catch( error ) {
date = null;
}
return date;
}
} );
</script>
</head>
<body>
<form class="form-horizontal well" method="post" action="/report">
<label for="from">From</label>
<input type="text" id="from" name="from">
<label for="to">To</label>
<input type="text" id="to" name="to">
<input class="button btn-default" type="submit" value="Gerar Relatório">
<table width="100%">