Custom Validate input

Daniel Braun pro premium priority asked 5 years ago

Hello Im trying to do a custom validator for an input but i dont quite understand how you trigger it. I looked at the example and there should be a javascript function right, or how would I trigger data-error?

<div class="md-form">
    <i class="fa fa-envelope prefix"></i>
    <input type="email" id="form9" class="form-control validate">
    <label for="form9" data-error="wrong" data-success="right">Type your email</label>
Hi daniel, if you want to validate an input text field (for example the length of the text) you could use the JS event onfocuscout, like below: <input type="text" onfocusout="myFunction()"> I hope this is what you need. Regards.
Hi daniel1, I understand that you need to display your own text validation.
<div class="md-form">
    <i class="fa fa-envelope prefix"></i>
    <input type="email" id="form9" class="form-control validate">
    <label for="form9" data-error="Your Text" data-success="right">Type your email</label>
If this is not what you need. Please describe the problem better and I will help you. Regards

Daniel Braun pro premium priority answered 5 years ago

Hello Thanks for the response What I'm looking for is how can I trigger it with a custom function? Example:

Function validateInput() {
    If (text is wrong) {
I want to write my own validator like validating the length. I know if it's a error it triggers data-error message but what I would like to know how does it trigger it? Thanks

jerrytunin pro answered 5 years ago

I think he is wondering how do you run data-error to display the default tooltip error message you see for everything???
Hi, You can easily pass text to data-error and data-success with a message content, all showing is doing in CSS. When you add to input class valid then a success message is shown, when invalid then error. Remove validate class from input to turn off default validation. Regards

xzesstence pro answered 3 years ago

its so typical for mdb that important stuff is unanswered.. this is so annyoing and people are paying for this...

you don't even have this with good open source...

both thumbs down @ mdb... as so often... i don't have so many thumbs to vote down this!

Marta Szymanska staff pro premium commented 3 years ago


would you explain where is exactly the problem? The most helpful would be if you create a snippet showing the problem here: Someone from our staff will help you, but please, specify your problem.

Best, Marta

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
  • User: Pro
  • Premium support: No
  • Technology: General Bootstrap questions
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No