【问题标题】:How did i validate required jqBootstrapValidation on IE9, iOS我如何在 IE9、iOS 上验证所需的 jqBootstrapValidation
【发布时间】:2012-12-21 15:07:24
【问题描述】:

对于这个例子,我只有一个带有 required 属性的输入字段,即使在 iOS Safari (iPhone/iPad) 和 IE9 上的值为空,我也会收到警报 OK。 Firefox 和 Chrome 运行良好。

我错过了什么吗?

<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <meta charset="utf-8">
        <title>jqBootstrapValidation by ReactiveRaven</title>

        <link rel="stylesheet" href="http://reactiveraven.github.com/jqBootstrapValidation/css/bootstrap.css">
        <script src="http://reactiveraven.github.com/jqBootstrapValidation/js/jQuery-1.7.2-min.js"></script>
        <script src="http://reactiveraven.github.com/jqBootstrapValidation/js/bootstrap.js"></script>
        <script src="http://reactiveraven.github.com/jqBootstrapValidation/js/jqBootstrapValidation.js"></script>

        <script>
            $(function() {
                $("input,textarea,select").jqBootstrapValidation(
                    {
                        preventSubmit: true,
                        submitError: function($form, event, errors) {
                            // Here I do nothing, but you could do something like display 
                            // the error messages to the user, log, etc.
                        },
                        submitSuccess: function($form, event) {
                            alert("OK");
                            event.preventDefault();
                        },
                        filter: function() {
                            return $(this).is(":visible");
                        }
                    }
                );
            });
        </script>

    </head>
    <body>
    <div class="tabbable">
        <ul class="nav nav-tabs">
            <li class="active"><a data-toggle="tab" href="#validators_required_preview">Example</a></li>
        </ul>
        <div class="tab-content">
            <div id="validators_required_preview" class="tab-pane active">
                <form class="form-horizontal">
                   <input name="some_field" required="" value="" type="text">
                   <button type="submit" class="btn btn-primary">Test Validation <i class="icon-ok icon-white"></i></button></form>
            </div>
        </div>
    </div>
</body></html>

【问题讨论】:

标签: javascript jquery validation


【解决方案1】:

您必须将输入字段包含在具有“控制组”类的 div 中

<div class="control-group">
<input name="some_field" required="" value="" type="text">
<p class="help-block"></p>
</div>

【讨论】:

    【解决方案2】:

    只是一个简短的说明。尽管在 IE 和 safari 中缺乏对“必需”属性的支持,这现在仍然有效。 这里的信息: http://reactiveraven.github.com/jqBootstrapValidation/

    【讨论】:

      猜你喜欢
      • 2013-07-23
      • 1970-01-01
      • 1970-01-01
      • 2020-05-29
      • 1970-01-01
      • 2012-09-03
      • 1970-01-01
      • 1970-01-01
      • 2021-03-08
      相关资源
      最近更新 更多