Topic: mdb-select validation support
SJMAZY@GMAIL.COM pro asked 7 years ago
$('.mdb-select').on('change', function(e){console.log(e.target.options[e.target.selectedIndex].value);console.log(e.target.options[e.target.selectedIndex].text);})
Are you able to provide an example on how to incorporate the above code with mdb-select field?
For example lets say the field
name ="test"
and I want to provide an error message if nothing is selected.How would I use the above code to validate the "test"
dropdown? SJMAZY@GMAIL.COM pro answered 7 years ago
Jakub Strebeyko staff commented 7 years ago
Dear SJMAZY@GMAIL.COM, Unfortunately, currently I cannot deliver mentioned solution. When it comes to the standard HTML5 validation method through "required" attribute, it is unsupported due to the nature of thematerial_select
function. The need for this feature is becoming more and more apparent though, so it has been added to our jQuery TODO.
With Best Regards,
Kuba
SJMAZY@GMAIL.COM pro answered 7 years ago
Jakub Strebeyko staff commented 7 years ago
Hi there SJMAZY@GMAIL.COM, We're working on improving MDB everyday, but nothing makes our effort worthwhile as people enjoying using the tool. Thank you! We're happy to know that you managed to resolve the issue -- and thanks for sharing it with us all! That's the community spirit that pushes us forward. I wish you many great projects & a good day, KubaFREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: No
- Technology: MDB jQuery
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No
Jakub Strebeyko staff commented 7 years ago
Dear SJMAZY@GMAIL.COM, Could you be more specific about the mechanism of validation you're mentioning? I'm guessing you do not mean displaying an error when there's no option chosen yet. The code you provided helps identifying particular options chosen, but does not disclose the context in which you're using material dropdown, not to mention the desired behavior (i.e. trigger for error message, like pressing the submit button in your form or clicking away of dropdown menu). With Best Regards, KubaSJMAZY@GMAIL.COM pro commented 7 years ago
.