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: https://mdbootstrap.com/snippets/standard/m-duszak/3462979

https://mdbootstrap.com/docs/standard/forms/select/#section-validation


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 11 months 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 11 months 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


https://mdbootstrap.com/snippets/standard/it_santini/3461531

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



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