Topic: How do I get the value of a datepicker?
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 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 commented 4 years ago
That's disappointing. I'll have to "role my own" functionality then.
Closed
This topic is closed.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Closed
- User: 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