How automatic validation for a form with several mdb-select


Topic: How automatic validation for a form with several mdb-select

Leo asked 4 years ago

Hello,

https://mdbootstrap.com/docs/jquery/forms/validation/#select

How detect and affect your code JS for validation when our form have several mdb-select required ? And get the current label for init the placeholder on the div mdb-select.

Thanks,


Krzysztof Wilk staff answered 4 years ago

Hi!

Every select in the form will be validated automatically. You can access them in the validation function. I made a snippet for you (select values and labels are in the console after submitting the form). Check it here: https://mdbootstrap.com/snippets/jquery/krzysztof-wilk/2752872#js-tab-view

Best regards


Leo commented 4 years ago

Hello Krzysztof,

Thanks but il all input are not required. In example for your snipet only one is required and the other no ?


Krzysztof Wilk staff commented 4 years ago

Hi!

Our JavaScript code is responsible for validation, so these selects don't have to have the required attribute. Anyway - you're right. It is additional Bootstrap security, so It is nice to have them. I corrected my snippet :)

Best regards


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
  • User: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.19.1
  • Device: Mac
  • Browser: Chrome
  • OS: Mac OS
  • Provided sample code: No
  • Provided link: Yes