aboutsummaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2015-02-21 21:58:35 -0500
committerScott González <scott.gonzalez@gmail.com>2015-02-23 12:21:21 -0500
commitfac8e517d7ea4c65bad21a65ad59eef1e4379efb (patch)
treee37c2c76a622498d4b667ffb4ee8f75d76dcb2a0 /demos
parent1e7a1e811f7c9d624b2561ea3e2f34f80773ad0c (diff)
downloadjquery-ui-fac8e517d7ea4c65bad21a65ad59eef1e4379efb.tar.gz
jquery-ui-fac8e517d7ea4c65bad21a65ad59eef1e4379efb.zip
Datepicker: Fix date range demo when entering values manually
Fixes #11143 Closes gh-1454
Diffstat (limited to 'demos')
-rw-r--r--demos/datepicker/date-range.html43
1 files changed, 28 insertions, 15 deletions
diff --git a/demos/datepicker/date-range.html b/demos/datepicker/date-range.html
index 34c64a9b2..8d606969c 100644
--- a/demos/datepicker/date-range.html
+++ b/demos/datepicker/date-range.html
@@ -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 );
- }
- });
- $( "#to" ).datepicker({
- defaultDate: "+1w",
- changeMonth: true,
- numberOfMonths: 3,
- onClose: function( selectedDate ) {
- $( "#from" ).datepicker( "option", "maxDate", 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;
}
- });
+
+ return date;
+ }
});
</script>
</head>