Daniel Braun priority asked 7 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>
</div>
thanks

xzesstence pro answered 4 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 ....ing ..it!


Marta Wierzbicka staff commented 4 years ago

Hi,

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

Best, Marta


Rafał Rogulski free answered 6 years ago


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

jerrytunin pro answered 6 years ago


I think he is wondering how do you run data-error to display the default tooltip error message you see for everything???

paolo.guerra free answered 7 years ago


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.

Daniel Braun priority answered 7 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) {
        display(data-error);
    }
}
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

Kamil Paciepnik free answered 7 years ago


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>
</div>
If this is not what you need. Please describe the problem better and I will help you. Regards

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