I am facing a problem while validating my form.
My html is :
<div class="form-group required">
<label for="address1" class="col-xs-12 col-sm-2 col-md-2 control-label">Address</label>
<div class="col-xs-12 col-sm-9 col-md-9">
<input type="text" class="form-control" name="address1" id="address1">
<label for="address1" class="control-label control-label-under">Address 1</label>
</div>
</div>
<div class="form-group required">
<div class="col-xs-12 col-sm-3 col-md-3 col-sm-offset-2 col-md-offset-2">
<input type="text" class="form-control" name="address_city" id="AddressCity">
<label class="control-label control-label-under" for="AddressCity">City</label>
</div>
<p class="row clearfix visible-xs-block"></p>
<div class="col-xs-12 col-sm-3 col-md-3 contact-state">
<input type="text" class="form-control" name="address_state" id="AddressEmirate">
<label class="control-label control-label-under" for="AddressEmirate">Emirate</label>
</div>
<p class="row clearfix visible-xs-block"></p>
<div class="col-xs-12 col-sm-3 col-md-3">
<input type="text" class="form-control" name="address_zip" id="AddressPostal">
<label class="control-label control-label-under" for="AddressPostal"></label>
</div>
</div>
<hr>
And the output is
Now the problem is as I need to display them inline so I put them inside same from-group and that is creating issue while validation.
I don't have any validation for postal code. But while validating if any of city/emirate validation fails then postal code also shown in red color. Which I don't want.
My question is how to display them inline as shown in the image but also keep them in separate form-group so that validation does not affect.
It's not difficult, can be achieved with the same HTML structure
Reason:
postal code
input highlighted red where it's not required and no validation rule set, because it's inside<div class="form-group required">
whereaddress_state
andaddress_city
are inside samediv
have validation rules set so if any of them invalid, error class.has-error .form-control
triggered and highlight thepostal code
input too.Fiddle example where
postal code
input highlighted red but no validation rule set to it.Solution: set custom error
selector
e.grow: '.col-xs-12',
inside validation rules so it will override the default error class.has-error .form-control
and only target the input inside<div class="form-group required">
which has validation rule set and has error.More Information
Plugin Example
Fiddle example with custom selector
SideNote: You have to expand the fiddle view to left, or run the above snippet in full page view they will be exactly like snapshot in question.