mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Datepicker: Fix date range demo when entering values manually
Fixes #11143 Closes gh-1454
This commit is contained in:
parent
1e7a1e811f
commit
fac8e517d7
@ -11,22 +11,35 @@
|
||||
<link rel="stylesheet" href="../demos.css">
|
||||
<script>
|
||||
$(function() {
|
||||
$( "#from" ).datepicker({
|
||||
defaultDate: "+1w",
|
||||
changeMonth: true,
|
||||
numberOfMonths: 3,
|
||||
onClose: function( selectedDate ) {
|
||||
$( "#to" ).datepicker( "option", "minDate", selectedDate );
|
||||
var dateFormat = "mm/dd/yy",
|
||||
from = $( "#from" )
|
||||
.datepicker({
|
||||
defaultDate: "+1w",
|
||||
changeMonth: true,
|
||||
numberOfMonths: 3
|
||||
})
|
||||
.on( "change", function() {
|
||||
to.datepicker( "option", "minDate", getDate( this ) );
|
||||
}),
|
||||
to = $( "#to" ).datepicker({
|
||||
defaultDate: "+1w",
|
||||
changeMonth: true,
|
||||
numberOfMonths: 3
|
||||
})
|
||||
.on( "change", function() {
|
||||
from.datepicker( "option", "maxDate", getDate( this ) );
|
||||
});
|
||||
|
||||
function getDate( element ) {
|
||||
var date;
|
||||
try {
|
||||
date = $.datepicker.parseDate( dateFormat, element.value );
|
||||
} catch( error ) {
|
||||
date = null;
|
||||
}
|
||||
});
|
||||
$( "#to" ).datepicker({
|
||||
defaultDate: "+1w",
|
||||
changeMonth: true,
|
||||
numberOfMonths: 3,
|
||||
onClose: function( selectedDate ) {
|
||||
$( "#from" ).datepicker( "option", "maxDate", selectedDate );
|
||||
}
|
||||
});
|
||||
|
||||
return date;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
Loading…
Reference in New Issue
Block a user