Note that there are some explanatory texts on larger screens.

plurals
  1. POhow can I add error classes to twitter bootstrap control group with multiple inputs ( not just 1 )
    primarykey
    data
    text
    <p>I have a form which i am trying to validate using the plugin validate at jquery.validate.js.</p> <p>you can see it at you can see the live page at:</p> <p><a href="http://optionhomes.net/index.php/test1/index" rel="nofollow">http://optionhomes.net/index.php/test1/index</a></p> <p>The form is loaded from a database. I want the form to have the bootstrap error class added to class 'control group' if a validation error occurs. According to my understanding of the bootstrap documentation, that is how to do it.</p> <p>I have HTML like so:</p> <pre><code>&lt;div class="form_row" &gt; &lt;div class="control-group"&gt; &lt;label class="control-label" for="input01"&gt;city&lt;/label&gt; &lt;div class="controls"&gt; &lt;input type="text" class="input-xlarge span3" id="city" name="city" value="&lt;?php echo $this-&gt;property-&gt;city ?&gt;" rel="popover" data-content="Re-enter your city." data-original-title="city" &gt; &lt;input type="text" class="input-xlarge span3" id="state" name="state" value="&lt;?php echo $this-&gt;property-&gt;state ?&gt;" rel="popover" data-content="Re-enter your state." data-original-title="state" &gt; &lt;input type="number" class="input-xlarge span2" id="zip" name="zip" value="&lt;?php echo $this-&gt;property-&gt;zip ?&gt;" rel="popover" data-content="Re-enter your zip code." data-original-title="zip" &gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>The jquery code is:</p> <pre><code> errorClass: "error", errorElement: "span", highlight:function(element, errorClass, validClass) { $(element).parents('.control-group').addClass('error'); }, unhighlight: function(element, errorClass, validClass) { $(element).parents('.control-group').removeClass('error'); $(element).parents('.control-group').addClass('success'); } </code></pre> <p>What I want to do is add the error class ( giving the red box ) to the input elements that fail validation. with my current code '.succes's classes are being added, turning these elements green , even when they need to be corrected.</p> <p>The problem as I understand it is that with the multiple inputs if the last 1 scanned by jquery passes validation a '.sucess class' ( green outline ) is added. I want the control group to have the red .error class assigned if just 1 of the 3 inputs fails validation, no matter what the order</p> <p>Thanks,</p> <p>Bill</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload