Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: How do I get the value of a datepicker?

edwolfe free asked 4 years ago


How do I get the value of the datepicker and timepicker? I'm using Jquery and can't find int he documentation where it tells me about any methods. Again, I need the date (preferrable formated wtih format Submit) and the time from timepicker.


Marcin Luczak staff answered 4 years ago


Hi,

To get the value of the datepicker you can listen to the change event and get the value of input inside the datepicker:

$('.datepicker').on('change', function() { const value = $('#input').val()) })

I made a snippet with a full example for you: https://mdbootstrap.com/snippets/jquery/marcin-luczak/2554327#js-tab-view


edwolfe free commented 4 years ago

Thank you for the reply. I am aware of the change event. What I was hoping for was to be able to get it when I needed it (without having to store it on the change event) with something like:

$('.datepicker').datepicker("getDate")

additionally it would be great if I would ask it for the date in one of the formats specified. For example,

$('.datepicker').datepicker("getDate", "formatSubmit")

Marcin Luczak staff commented 4 years ago

Unfortunately, Datepicker doesn't have that kind of functionality at the moment. We will consider adding those methods in future releases. Best regards, Marcin


edwolfe free commented 4 years ago

That's disappointing. I'll have to "role my own" functionality then.


FREE CONSULTATION

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

Status

Closed

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