Implement MDB-Select server-side validation


Topic: Implement MDB-Select server-side validation

IT_Santini pro premium priority asked 2 months 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 months ago

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


Michał Duszak staff answered 2 months 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 pro premium priority commented 2 months 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 months 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.


IT_Santini pro premium priority answered 2 months 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.
Status

Answered

Specification of the issue
  • User: Pro
  • 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