首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >BootstrapValidator不提交表单

BootstrapValidator不提交表单
EN

Stack Overflow用户
提问于 2017-01-11 20:47:38
回答 2查看 351关注 0票数 1

我尝试过使用BootstrapValidator,但由于某种原因,除非我删除JS脚本,否则它不会提交表单。

JS脚本是:

代码语言:javascript
复制
$(document).ready(function() {
    $('#loginForm').bootstrapValidator({
        framework: 'bootstrap',
        icon: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            email: {
                validators: {
                    notEmpty: {
                        message: 'The email address is required'
                    },
                    emailAddress: {
                        message: 'The input is not a valid email address'
                    }
                }
            },
            pass: {
                validators: {
                    notEmpty: {
                        message: 'The password is required'
                    },
                    different: {
                        field: 'email',
                        message: 'The password cannot be the same as username'
                    }
                }
            },
        }
    });
});

我的表格:

代码语言:javascript
复制
 <div class="col-sm-4 col-sm-offset-5 col-md-4 col-md-offset-5 main">
 <h1 class="page-header">Please sign in</h1>
      <form id="loginForm" class="form-signin" action="ApplicantLogin.php" method="POST">
        <label for="inputEmail" class="sr-only">e-Mail</label>
        <input type="text" id="inputEmail" class="form-control" placeholder="e-Mail" name="email" required autofocus>
        <label for="inputPassword" class="sr-only">Password</label>
        <input type="password" id="inputPassword" class="form-control" placeholder="Password" name="pass" required>
        <div class="checkbox">
          <label>
            <input type="checkbox" value="remember-me"> Remember me
          </label>
        </div>
        <button class="btn btn-lg btn-primary btn-block" name="loginbtn" value="login">Sign in</button>
      </form>

    </div> <!-- /container -->

正如创建者所建议的那样,我已经将按钮名更改为与默认值不同的名称,但仍然无法工作。知道为什么吗?不过,验证工作还不错。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-01-11 21:20:53

您的表单没有提交,因为您没有submit按钮。将type="submit"添加到其中。

代码语言:javascript
复制
<button type="submit" class="btn btn-lg btn-primary btn-block" name="loginbtn" value="login">Sign in</button>
票数 0
EN

Stack Overflow用户

发布于 2017-01-11 22:15:45

我已经尝试过您在我的localhost中提供的代码,它可以工作。我尝试在这里插入相同的小提琴,控制台显示了以下错误:

引导验证器不是一个函数。

由于某种原因,插件似乎没有加载。也许这就是你网络上发生的事。要解决这个问题,您可以链接引导程序验证程序库:

代码语言:javascript
复制
//cdnjs.cloudflare.com/ajax/libs/bootstrap-validator/0.4.5/css/bootstrapvalidator.min.css


//cdnjs.cloudflare.com/ajax/libs/bootstrap-validator/0.4.5/js/bootstrapvalidator.min.js

如果验证器正在工作,它应该使用您拥有的按钮提交,如果单击空输入,它应该会显示一条消息。

  • 如果记录相同的错误,请检查控制台日志。
  • 检查jquery是否有关联。

这是到小提琴工作的链接。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41600408

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档