Topic: How do disable a datepicker?

edwolfe free asked 4 years ago


How do I disable a datepicker? By disable, I mean the user is unable to click on it and it won't display the date selection box.

I have the following HTML/JavaScript:

<div id='templ_setting_hours_dateGroup_Start' class='md-form input-group md-outline input-with-pre-icon datepicker disabled'>
                          <input id='startDate' name='startDate'  type='text' id='startDate' class='form-control w-100'>
                          <label for='startDate'>Start</label>
                          <i class='fas fa-calendar input-prefix' tabindex=0></i>
                      </div>

$('#templ_setting_hours_dateGroup_Start').datepicker({
                altInput: true,
                altFormat: "F j, Y",
                dateFormat: "Y-m-d"
            });

Grzegorz Bujański staff commented 4 years ago

Hi. I see that you created a similar topic earlier and Tomek sent a possible solution. Is something still not working as you like?


edwolfe free commented 4 years ago

That was for timepicker. I assume you are saying the same solution will work for date picker? Below is the reply I gave Tomek:

"Ok. This solved it. I would like to request an enhancement so that the control could be told to be disabled or enabled. Something like $('.time-picker').timepicker('disabled', 'true') or similar. Makes for cleaner code (and less error prone) than having add disabled to 3 labels (or even need to add it to all children)."


Grzegorz Bujański staff commented 4 years ago

I didn't notice that it was a timepicker, not a datepicker. But that solution should work in both cases. I will also add a task in our list of ideas for adding a disabled option for timepicker and datepicker. Maybe one day we will add this functionality.



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.19.1
  • Device: ALL
  • Browser: ALL
  • OS: ALL
  • Provided sample code: No
  • Provided link: No