Topic: Implement MDB-Select server-side validation

IT_Santini priority asked 2 years ago

Expected behavior When server side validation return error on select field, it can add is-invalid class and display div class="invalid-feedback" with error message text below select input

Actual behavior When server side validation return error on select field, it cannot set styling with just adding is-invalid class or add div class="invalid-feedback" with error message text displayed

Resources (screenshots, code snippets etc.)

Michał Duszak staff commented 2 years ago

Hello, how is your validation implemented? Could you show me a snippet which will reproduce this behaviour?

Michał Duszak staff answered 2 years ago

Here's a proper validation for Select:

IT_Santini priority commented 2 years ago

From your example, validation happens at client side. What I'm trying to achieve is validation from server side. For Example: User cannot choose option two, but the validation check is done in server, not in client side How can I achieve this?

Michał Duszak staff commented 2 years ago

This is the provided validation for the select input MDB provides. It checks if select provides any option. If you wouldn't like user to provide certain options, you could disable them, or check their values on the server side, and then clear the select's value so that it will display invalid styles.

Swindler free answered 1 year ago

has this problem not been resolved? the issue described is when you create a select element, mdb.js creates an input counterpart while hiding the original select. The select is the only thing that retains the class 'is-invalid' and does not extend that class over to the newly created input field.

This is annoying because it works this way with every other field type except select. is there a solution to this problem?

Mateusz Lazaru staff commented 1 year ago

It creates input and the input gets :invalid or :valid pseudo classes. Dispalyed feedback message is based on the pseudo class.

IT_Santini priority answered 2 years ago

here is the snippet of what i'm trying to achieve, should have error styling and message

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.10.0
  • Device: Laptop
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No