1

Regarding to this answer my following code should work:

<form data-toggle="validator">
  <div class="form-group has-feedback">
    <label for="exampleInputText">Name</label>
    <input type="text" class="form-control" id="exampleInputText" placeholder="text" data-odd>
    <span class="glyphicon form-control-feedback" aria-hidden="true"></span>
    <div class="help-block with-errors"></div>
</form>

<script type="text/javascript">
  $('form').validator({
    custom: {
      'odd': function($el) { return false }
    },
    errors: {
      'odd': 'error message'
    }
  })
</script>

But it does not work - why?

Community
  • 1
  • 1
Jurik
  • 3,244
  • 1
  • 31
  • 52
  • At least it gets bound, because when I do not set errors message, I'll get an js error. – Jurik May 27 '16 at 15:26

1 Answers1

2

You should remove

data-toggle="validator"

from the form tag, and update the input with id exampleInputText as follows (i.e. adding ="odd" to data-odd):

data-odd="odd"

Example here: https://jsfiddle.net/mdt86/9r06waph/10/

MDT
  • 1,599
  • 4
  • 18
  • 26