Topic: Add required to datepicker
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:true
inside 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?
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
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Free
- Premium support: No
- Technology: MDB jQuery
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: Yes
- Provided link: Yes