rewrite of earlier question of jquery plugin validation with twitter bootstrap
Hi everyone,
I am rewriting this question to hopefully crystallize my question better:
I am new to jquery and JS. I have a form which I am building with twitter bootstrap and trying to validate using the plugin validate at jquery.validate.js.
You can see the live page at:
http://optionhomes.net/index.php/test1/index
I have a row with 3 input fields. If any of the inputs fail validation I want an error class to be added to the parent .control-group class.i figured I would iterate through the input elements of the row and check each to see if they pass validation if 1 doesn't I set a variable ( valid ) to false for the entire row. I can then add the error class after.
So far, I have the following jquery code, but I'm getting a syntax error. Can someone give me some pointers?
The element function is from http://docs.jquery.com/Plugins/Validation/Validator/element#overview
- var valid = true;
$('.controls').children.each(function{if(!$(this).validate().element()) {valid=false} })
Here is the HTML for the row:
- <div class="form_row" >
<div class="control-group">
<label class="control-label" for="input01">city</label>
<div class="controls">
<input type="text" class="input-xlarge span3" id="city" name="city" value="<?php echo $this->property->city ?>" rel="popover" data-content="Re-enter your city." data-original-title="city" >
<input type="text" class="input-xlarge span3" id="state" name="state" value="<?php echo $this->property->state ?>" rel="popover" data-content="Re-enter your state." data-original-title="state" >
<input type="number" class="input-xlarge span2" id="zip" name="zip" value="<?php echo $this->property->zip ?>" rel="popover" data-content="Re-enter your zip code." data-original-title="zip" >
</div>
</div>
</div>
Thanks in advance,
Bill