Topic: How do I programmatically mark a Select as being valid / invalid

UNNdev priority asked 3 years ago


A regular input can be marked as valid or invalid by setting the is-valid or is-invalid class on the form-outline after a server-side validation when generating the markup using Blade or Twig for example.

How can you set a select as valid / invalid? The div class="form-outline" is generated by MDB when creating a new instance and there doesn't seem to be a data-mdb-* attribute I can set to hint the lib to automatically add is-valid or is-invalid to the generated wrapper.

data-mdb-validation works only with browser validation and only marks the input as being required.

Do I have to add the classes to the select-input wrapper with JS after the component was initialized?


Dawid Wajszczuk staff answered 3 years ago


Hi,

It is the best solution to add is-valid, is-invalid classes to the select-input via JS after the Select initialization.

Keep coding,
Dawid



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: Priority
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 3.9.0
  • Device: PC
  • Browser: Chrome
  • OS: Windows
  • Provided sample code: Yes
  • Provided link: No