Jquery Form Validation Position of the error div in select fields

Asked

Viewed 351 times

1

To change the position of the error text in fields Select2. is appearing above the field, I want it to appear below! Any hint?

inserir a descrição da imagem aqui

<!-- /field -->
<div class="col-md-3">
<div class="form-group">
<label class="control-label">SEXO
<span class="required"> * </span>
</label>

<select name="sexo" id="sexo" class="form-control select2" tabindex="9" required>

<? 
if($Obj->sexo=="F") $sexo = "Feminino"; 
if($Obj->sexo=="M") $sexo = "Masculino";
?>

<optgroup label="">
<option value="<?=$Obj->sexo?>" selected > <?=$sexo?> </option>
</optgroup>

<optgroup label="...">
<option value="F">Feminino  </option>       
<option value="M">Masculino </option>       
</optgroup>
</select>

</div>
</div>
<!-- /field -->



<!-- field -->
<div class="col-md-6">
<div class="form-group">
<label class="control-label">NOME COMPLETO
<span class="required"> * </span>
</label>

<div class="input-icon right"><i class="fa"></i>
<input type="text" autofocus onfocus="select(this);" id="nomecompleto" name="nomecompleto" minlength="3" maxlength="150" class="form-control jump" 
    value="<?=htmlspecialchars($Obj->nomecompleto)?>" required tabindex="2">
</div></div>
</div>
<!-- /field -->
  • 2

    Add the question the code used to help you

  • I believe it is a super simple error.. go to your html code in the sex input. copy the tag above it and pass it down, you should solve.

  • Also put the html of the full name field, to compare with the gender and see the position of the tags in each one.

  • The code is only to innervate an asterisk! No effect has appeared, remains the same problem. I believe it must be something within the jquery form validation... but I don’t know where.

1 answer

1

I Managed to Resolve.

Inside the js file that has the form validation function has the option to errorplacement, then just create the element after finding the element with the desired class. It worked 100%.

if (element.parent(".form-group").size() > 0) {
  error.insertAfter(element.next('.select2'));
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.