Topic: Validation on mdbselect

sandor farkas priority asked 3 years ago

Expected behavior I want to validate mdbselect with html5 validation. What would be the right way to validate a mdbselect field? In my case I want to have a required select field.

Actual behavior Since mdbselect is no default input element I suppose validation is not supported.

Resources (screenshots, code snippets etc.)

sandor farkas priority answered 3 years ago

thank you @Michał Duszak This helped me. Thank you

Michał Duszak staff answered 3 years ago

sandor farkas priority answered 3 years ago

Hey thank you for your reply. The snippet does not seem to be related to my problem as far as I can see it.

Michał Duszak staff answered 3 years ago

It's possible to create custom validation functions, for example:

I created a custom function to check if the select element's value is 'One' , and created custom classes to append custom valid/invalid notches.

function checkSelectValidation(event) {
      if (select.value == 'One') {
        const selectWrapper = document.querySelector('.validate-select');

      if(select.value !== 'One') {
        const selectWrapper = document.querySelector('.validate-select');

It's also important that you wrap your select in a div, so that you can refer to it all the time it's in the DOM.

Please insert min. 20 characters.


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



Specification of the issue

  • ForumUser: Priority
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 3.5.1
  • Device: web
  • Browser: chrome
  • OS: win10
  • Provided sample code: No
  • Provided link: Yes