How to disable the click event on "Date Range Picker" days?

Asked

Viewed 77 times

0

I’m trying to stop the "click" event on each day of the Daterangepicker, I’m just trying to stop users from changing the period.

I created a thumb drive in Codepen, follow link: https://codepen.io/jnts/pen/yQPwmB

HTML

<input data-start="16/11/2018" data-end="16/12/2018" type="text" name="dates">

Javascript

const self = $('input[name="dates"]')

self.daterangepicker({
    applyButtonClasses: 'd-none',
    showDropdowns: false,
    opens: "center",
    drops: "down",
    autoApply: false,
    startDate: self.data('start'),
    endDate: self.data('end'),
    minDate: self.data('start'),
    maxDate: self.data('end'),
    locale: {
      format: "DD/MM/YYYY",
      separator: " - ",
      firstDay: 1
    }
});

I already tried to add the attribute "disabled" in the input, but this only prevents the click event on input, so the Daterangepicker doesn’t even show up.

I just want to show the period in a mode 'read-only'.

  • 1

    Welcome to the Stackoverflow in Portuguese. As the name suggests, the official language used here is Portuguese. So, could you please translate your question? If you prefer, you can also ask the same question on Stackoverflow website in English.

  • There, researching here, the DataeRangerPicer has no option 'readonly'. Taking advantage that you are already using jquey, try using Datepicker of the same, already used and know that there are ways to implement your scenario, below I will list some links that can you ajduar: - Documentation Jquey datepicker: https://jqueryui.com/datepicker/ - How to let Jquery datepicker read-only: https://stackoverflow.com/questions/7812063/jquery-datepicker-readonly It’s worth taking a look at this last link, as the scenery is very similar to yours! Hope I helped, hugs!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.