question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

From & to calendars

See original GitHub issue

Hey. I can’t seem to find an example as to how to do this with the new v3 api. Could you please advise?

Here is how it’s done with the jquery ui datepicker:

 $( "#from" ).datepicker({
onClose: function( selectedDate ) {
$( "#to" ).datepicker( "option", "minDate", selectedDate );
}
});

$( "#to" ).datepicker({
onClose: function( selectedDate ) {
$( "#from" ).datepicker( "option", "maxDate", selectedDate );
}
});

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
akash-sutharcommented, Aug 9, 2016

$(‘.datepicker’).on(‘change’, function () { if ($(this).attr(‘id’) === ‘datefrom’) { alert($(this).val()) $(‘#dateto’).pickadate(‘picker’).set(‘min’,$(this).val()); } if ($(this).attr(‘id’) === ‘dateto’) { $(‘#datefrom’).pickadate(‘picker’).set(‘max’,$(this).val()); } });

1reaction
dbr0commented, Jul 26, 2017

An upgrade from what @akash-suthar did:

$('.datepicker').on('change', function () {
//$(document).on('change', '.datepicker', function () { //use this line if you create datepickers dynamically
    if ($(this).data('datepicker_from_or_to') === 'from') {
        $('#'+$(this).data('datepicker_to_target')).pickadate('picker').set('min',$(this).val());
    }
    if ($(this).data('datepicker_from_or_to') === 'to') {
        $('#'+$(this).data('datepicker_from_target')).pickadate('picker').set('max',$(this).val());
    }
});

and in the html

<input type="date"
                       class="datepicker"
                       id="start_date"
                       data-datepicker_from_or_to="from"
                       data-datepicker_to_target="end_date"
                >

and

<input type="date"
                       class="datepicker"
                       id="end_date"
                       data-datepicker_from_or_to="to"
                       data-datepicker_from_target="start_date"
                >
Read more comments on GitHub >

github_iconTop Results From Across the Web

Date Duration Calculator: Days Between Dates - Time and Date
Calendar with Logo (PDF). Add your company logo to our printable calendars. Illustration image. Date Calculator API. Find a ...
Read more >
Form to Calendar - Google Workspace Marketplace
Create event by submitting form, turn form response into Google Calendar event. Generate a form with start time and end time fields for...
Read more >
Create & share a group calendar - Google Support
These are called group calendars. For example, you might want a shared group calendar for company holidays and another one for organization-wide meetings....
Read more >
Set up multiple calendars on iPhone - Apple Support
You can keep track of all your events and appointments in one calendar, but additional calendars are easy to set up and a...
Read more >
Introduction to Calendars
A calendar is a system of organizing units of time for the purpose of reckoning time over extended periods. There are six principal...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found