nghuuphuoc 11 年之前
父节点
当前提交
8bd3b5378f
共有 6 个文件被更改,包括 15 次插入104 次删除
  1. 1 1
      demo/attribute.html
  2. 0 83
      demo/dynamic.html
  3. 1 1
      demo/validators.html
  4. 6 9
      dist/js/bootstrapValidator.js
  5. 1 1
      dist/js/bootstrapValidator.min.js
  6. 6 9
      src/js/bootstrapValidator.js

+ 1 - 1
demo/attribute.html

@@ -81,7 +81,7 @@
                         <div class="col-lg-5">
                             <div class="radio">
                                 <label>
-                                    <input type="radio" name="gender" value="male" required data-vb-notempty-message="The gender is required" /> Male
+                                    <input type="radio" name="gender" value="male" required data-bv-notempty-message="The gender is required" /> Male
                                 </label>
                             </div>
                             <div class="radio">

+ 0 - 83
demo/dynamic.html

@@ -1,83 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-    <title>BootstrapValidator demo</title>
-
-    <link rel="stylesheet" href="../vendor/bootstrap/css/bootstrap.css"/>
-    <link rel="stylesheet" href="../dist/css/bootstrapValidator.css"/>
-
-    <script type="text/javascript" src="../vendor/jquery/jquery-1.10.2.min.js"></script>
-    <script type="text/javascript" src="../vendor/bootstrap/js/bootstrap.min.js"></script>
-    <script type="text/javascript" src="../dist/js/bootstrapValidator.js"></script>
-</head>
-<body>
-<div class="container">
-    <div class="row">
-        <!-- form: -->
-        <section>
-            <div class="col-lg-8 col-lg-offset-2">
-                <div class="page-header">
-                    <h2>Support dynamic elements</h2>
-                </div>
-
-                <form id="defaultForm" method="post" class="form-horizontal" action="target.php">
-                    <p>What programming languages are you good at?</p>
-
-                    <div class="form-group hide" id="template">
-                        <div class="col-lg-4"><input class="form-control" type="text" /></div>
-                    </div>
-
-                    <div class="form-group">
-                        <div class="col-lg-4"><input class="form-control" type="text" name="languages[]" /></div>
-                        <div class="col-lg-4"><button type="button" class="btn btn-success" id="addButton">Add more</button></div>
-                    </div>
-
-                    <div class="form-group">
-                        <div class="col-lg-4"><input class="form-control" type="text" name="languages[]" /></div>
-                    </div>
-
-                    <div class="form-group">
-                        <div class="col-lg-3">
-                            <button type="submit" class="btn btn-primary">Hire me</button>
-                        </div>
-                    </div>
-                </form>
-            </div>
-        </section>
-        <!-- :form -->
-    </div>
-</div>
-
-<script type="text/javascript">
-    $(document).ready(function() {
-        $('#defaultForm').bootstrapValidator({
-            message: 'This value is not valid',
-            feedbackIcons: {
-                valid: 'glyphicon glyphicon-ok',
-                invalid: 'glyphicon glyphicon-remove',
-                validating: 'glyphicon glyphicon-refresh'
-            },
-            fields: {
-                'languages[]': {
-                    validators: {
-                        notEmpty: {
-                            message: 'The language name is required'
-                        }
-                    }
-                }
-            }
-        });
-
-        $('#addButton').on('click', function() {
-            var formGroup = $(this).parents('.form-group');
-            $('#template')
-                .clone()
-                .removeAttr('id')
-                .removeClass('hide')
-                    .find('input').attr('name', 'language[]').end()
-                .insertAfter(formGroup);
-        });
-    });
-</script>
-</body>
-</html>

+ 1 - 1
demo/validators.html

@@ -20,7 +20,7 @@
                 </div>
 
                 <div class="col-lg-8 col-lg-offset-2">
-                    <form id="defaultForm" method="post" action="validators.html" class="form-horizontal">
+                    <form id="defaultForm" method="post" action="target.php" class="form-horizontal">
                         <fieldset>
                             <legend>Not Empty validator</legend>
 

+ 6 - 9
dist/js/bootstrapValidator.js

@@ -168,7 +168,6 @@
                 });
 
             this.options = $.extend(true, this.options, options);
-            //console.log(this.options);
 
             for (var field in this.options.fields) {
                 this._initField(field);
@@ -200,11 +199,6 @@
                 }
             }
 
-            // Set the attribute to indicate the fields which are defined by selector
-            if (!fields.attr('data-bv-field')) {
-                fields.attr('data-bv-field', field);
-            }
-
             var that      = this,
                 type      = fields.attr('type'),
                 event     = ('radio' == type || 'checkbox' == type || 'file' == type || 'SELECT' == fields[0].tagName) ? 'change' : 'keyup',
@@ -217,6 +211,11 @@
                     // Allow user to indicate where the error messages are shown
                     $message = this.options.fields[field].container ? $parent.find(this.options.fields[field].container) : this._getMessageContainer($field);
 
+                // Set the attribute to indicate the fields which are defined by selector
+                if (!$field.attr('data-bv-field')) {
+                    $field.attr('data-bv-field', field);
+                }
+
                 // Whenever the user change the field value, mark it as not validated yet
                 $field.on(event + '.bv', function() {
                     updateAll ? that.updateStatus(field, that.STATUS_NOT_VALIDATED, null)
@@ -308,7 +307,7 @@
                                 }).join(' ');
 
                             for (var i = 0; i < total; i++) {
-                                $(fields[i]).on(events, function () {
+                                $(fields[i]).on(events, function() {
                                     updateAll ? that.validateField(f) : that.validateFieldElement($(this), false);
                                 });
                             }
@@ -507,8 +506,6 @@
                 $errors  = $message.find('.help-block[data-bv-validator]'),
                 $icon    = $parent.find('.form-control-feedback[data-bv-field="' + field + '"]');
 
-            console.log(field, validatorName, status);
-
             // Update status
             if (validatorName) {
                 $field.data('bv.result.' + validatorName, status);

文件差异内容过多而无法显示
+ 1 - 1
dist/js/bootstrapValidator.min.js


+ 6 - 9
src/js/bootstrapValidator.js

@@ -167,7 +167,6 @@
                 });
 
             this.options = $.extend(true, this.options, options);
-            //console.log(this.options);
 
             for (var field in this.options.fields) {
                 this._initField(field);
@@ -199,11 +198,6 @@
                 }
             }
 
-            // Set the attribute to indicate the fields which are defined by selector
-            if (!fields.attr('data-bv-field')) {
-                fields.attr('data-bv-field', field);
-            }
-
             var that      = this,
                 type      = fields.attr('type'),
                 event     = ('radio' == type || 'checkbox' == type || 'file' == type || 'SELECT' == fields[0].tagName) ? 'change' : 'keyup',
@@ -216,6 +210,11 @@
                     // Allow user to indicate where the error messages are shown
                     $message = this.options.fields[field].container ? $parent.find(this.options.fields[field].container) : this._getMessageContainer($field);
 
+                // Set the attribute to indicate the fields which are defined by selector
+                if (!$field.attr('data-bv-field')) {
+                    $field.attr('data-bv-field', field);
+                }
+
                 // Whenever the user change the field value, mark it as not validated yet
                 $field.on(event + '.bv', function() {
                     updateAll ? that.updateStatus(field, that.STATUS_NOT_VALIDATED, null)
@@ -307,7 +306,7 @@
                                 }).join(' ');
 
                             for (var i = 0; i < total; i++) {
-                                $(fields[i]).on(events, function () {
+                                $(fields[i]).on(events, function() {
                                     updateAll ? that.validateField(f) : that.validateFieldElement($(this), false);
                                 });
                             }
@@ -506,8 +505,6 @@
                 $errors  = $message.find('.help-block[data-bv-validator]'),
                 $icon    = $parent.find('.form-control-feedback[data-bv-field="' + field + '"]');
 
-            console.log(field, validatorName, status);
-
             // Update status
             if (validatorName) {
                 $field.data('bv.result.' + validatorName, status);