简体   繁体   中英

Bootstrap-validator not displaying errors

I have the following form that I want to use the bootstrap-validator :

<form method="POST" action="http://localhost:8000/register/researcher" accept-charset="UTF-8" data-toggle="validator" novalidate="true">
    <input name="_token" type="hidden" value="v5VF4sgb0zOrxzAihpEhkezccUWHPpXO5CnnmIK7">
<div class="from-group">
    <input class="form-control" placeholder="Nome" required="required" name="name" type="text">
</div>
<br>
<div class="from-group">
    <input class="form-control" placeholder="Email" data-error="O email inserido é inválido." required="required" name="email" type="email">
    <div class="help-block with-errors"></div>
</div>
<br>
<div class="from-group">
    <input class="form-control" placeholder="Senha" data-minlength="6" id="inputPass" required="required" name="password" type="password" value="">
    <span class="help-block">Senha de no mínimo 6 caracteres</span>
</div>
<br>
<div class="from-group">
    <input class="form-control" placeholder="Confirmar senha" data-match="#inputPass" data-match-error="Senhas inseridas são diferentes" required="required" name="password_confirmation" type="password" value="">
    <div class="help-block with-errors"></div>
</div>
<br>
<div class="from-group">
    <input class="form-control" placeholder="CPF" required="required" name="cpf" type="text">
</div>
<br>
<div class="text-center">
    <input class="btn btn-primary disabled" type="submit" value="Enviar">
</div>                </form>

I'm importing the validator.js and somehow it's working (it disables the submit button) but no erros are shown when I test the form. Can you help me to find where I'm doing something wrong?

(Plus: I'm using the laravel HTML Form Facades to generate this form)

  1. Update the class from-group to form-group .
  2. Init bootstrapValidator instance by the following code.

     $(function () { $("#your form id").bootstrapValidator(); ); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM