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: Add required to datepicker

free asked 7 years ago


I would like to make a datepicker input field required but I don't seem to be able to get it right.

I read this section: https://mdbootstrap.com/javascript/date-picker/#editable-input

And then added the editable:trueinside the initialization together with the required attribute on the element.

However, the datepicker modal no longer opens on click after that. Any suggestions for a fix?

Thanks!



andreaHandlebars free answered 5 years ago


Hi that plugin https://jqueryvalidation.org doesn't work, because there's a conflic with internal mdbootstrap's validator. Can you help me?


Piotr Glejzer staff commented 5 years ago

Hi, do you have some console errors to show?



Jakub Strebeyko staff answered 7 years ago


Hi there library_manager,

As you surely see, the "Please fill out this field" tooltip popping up is a plain, HTML5-style validation applied through the required attribute. To have this kind of validation working, the Date Picker must first become a regular, HTML5-recognizable input field (which is done by passing in the editable: true option). And so, clicking onto it can no longer trigger the date-picking popover, but enables "manual" edits of the field instead.

To have both the MDB Date Picker and validation it's worth to consider creation of a custom validating function on submit or using some widely recognized plugins, like .validate().

With Best Regards,
Kuba




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: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: Yes
  • Provided link: Yes
Tags