jqBootstrapValidation icon indicating copy to clipboard operation
jqBootstrapValidation copied to clipboard

Unable to Get Data Validation Messages To Work

Open robred opened this issue 11 years ago • 10 comments

I left a comment in number 56, but that issue was closed (without explanation of how it was resolved).

I am having the same issue the OP had in #56 - namely the validation messages aren't appearing, and adding novalidate just allows the form to submit.

I am using jquery 1.9.1, don’t know if that would matter.

This is the jquery I'm using for the validator:

$().ready(function(){
  $("input,select,textarea").not("[type=submit]").jqBootstrapValidation();

And this is the HTML:

<div class="span4">
    <label for="projcode-cost-center" class="required">Project Code/Cost Center*</label>
    <input id="projcode-cost-center" name="projcode-cost-center" type="text" required placeholder="Project Code/Cost Center" data-validation-required-message="A Project Code/Cost Center is required.">
</div>

robred avatar May 21 '13 19:05 robred

+1 on this, it always gives me the default browser message.

thelinuxlich avatar May 29 '13 18:05 thelinuxlich

I'm having the same issue with jquery 1.9.1

benedict-w avatar Jul 18 '13 12:07 benedict-w

+1 same problem but the message are personalized in the demo. Seem buggy on FF only, ok on chrome.

mikecastrodemaria avatar Jul 22 '13 20:07 mikecastrodemaria

Same issue here with jquery v1.10.2 any idea on how to fix it?

renini avatar Aug 17 '13 08:08 renini

Your fields needs to have this basic structure:

<div class="control-group">
  <label for="some_field">Your label</label>
  <div class="controls">
    <input type="text" name="some_field" required>
  </div>
</div>

Watch out for the classes "control-group" and "controls", they're required in each input you want to validate with this plugin!

acemir avatar Aug 17 '13 18:08 acemir

Oeps, I missed the

tag.

renini avatar Aug 26 '13 17:08 renini

@robred, could you create a JSFiddle or Plunker to reproduce this?

chrisirhc avatar Aug 26 '13 18:08 chrisirhc

This code worked for me with Bootstrap 3, Jquery 1.10.2 and jqBootstrapValidation 1.3.6.

<form novalidate> 
<div class="control-group">
  <label for="some_field">Your label</label>
  <div class="controls">
    <input type="text" name="some_field" class="form-control" required  data-validation-required-message="This field is required.">
    <p class="help-block"></p>
  </div>
</div>
<button class="btn btn-primary pull-right" type="submit">Submit</button>
<br />
</form>

<script>
$(document).ready(function() {
 $("input,select,textarea").not("[type=submit]").jqBootstrapValidation(); 
});
</script>

Jsfiddle example

http://jsfiddle.net/Onelove/2Cyph/

kmd1970 avatar Oct 09 '13 15:10 kmd1970

The comment about "control-group" and "controls" was what helped me out. Thanks @acemir!

developering avatar Nov 13 '15 15:11 developering

By the way I have found that version 1.3.6 has two variants floating around. One looks for "form-groups" and one doesn't. So it may work without "controls" and "control-group" and work with "form-groups" OR it may not!

scandox avatar Apr 12 '16 13:04 scandox