1

我有以下表格,我想使用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>

我正在导入 validator.js 并且它以某种方式工作(它禁用了提交按钮)但是当我测试表单时没有显示错误。你能帮我找出我做错了什么吗?

(另外:我正在使用 laravel HTML Form Facades 来生成这个表单)

4

1 回答 1

3
  1. 将类更新from-groupform-group.
  2. 通过以下代码初始化 bootstrapValidator 实例。

    $(function () {
        $("#your form id").bootstrapValidator();
    );
    
于 2015-08-24T05:32:36.930 回答