mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
4c22343281
Ref #10119
53 lines
1.2 KiB
HTML
53 lines
1.2 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>jQuery UI Datepicker - Select a Date Range</title>
|
|
<link rel="stylesheet" href="../../themes/base/all.css">
|
|
<link rel="stylesheet" href="../demos.css">
|
|
<script src="../../external/requirejs/require.js"></script>
|
|
<script src="../bootstrap.js">
|
|
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;
|
|
}
|
|
|
|
return date;
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
|
|
<label for="from">From</label>
|
|
<input type="text" id="from" name="from"/>
|
|
<label for="to">to</label>
|
|
<input type="text" id="to" name="to"/>
|
|
|
|
<div class="demo-description">
|
|
<p>Select the date range to search for.</p>
|
|
</div>
|
|
</body>
|
|
</html>
|