Browse Source

#70: Support custom grid columns

nghuuphuoc 11 years ago
parent
commit
1ec8537ded
5 changed files with 16 additions and 3 deletions
  1. 1 0
      CHANGELOG.md
  2. 4 0
      README.md
  3. 5 1
      dist/js/bootstrapValidator.js
  4. 1 1
      dist/js/bootstrapValidator.min.js
  5. 5 1
      src/js/bootstrapValidator.js

+ 1 - 0
CHANGELOG.md

@@ -8,6 +8,7 @@ __New features__:
 * #26, #27, #67: Add choice validator
 * [#64: Support Danish zip code](https://github.com/nghuuphuoc/bootstrapvalidator/issues/64)
 * [#65: Support Sweden zip code](https://github.com/nghuuphuoc/bootstrapvalidator/issues/64)
+* [#70: Support custom grid columns](https://github.com/nghuuphuoc/bootstrapvalidator/issues/70)
 * [#71: Show all errors](https://github.com/nghuuphuoc/bootstrapvalidator/issues/71)
 
 __Fixes__:

+ 4 - 0
README.md

@@ -67,6 +67,10 @@ $(document).ready(function() {
         // You can specify the error message for any fields
         message: ...,
 
+        // The number of grid columns
+        // Change it if you use custom grid with different number of columns
+        columns: 12,
+
         // The submit buttons selector
         // These buttons will be disabled when the form input are invalid
         submitButtons: ...,

+ 5 - 1
dist/js/bootstrapValidator.js

@@ -34,6 +34,10 @@
         // Default invalid message
         message: 'This value is not valid',
 
+        // The number of grid columns
+        // Change it if you use custom grid with different number of columns
+        columns: 12,
+
         // The custom submit handler
         // It will prevent the form from the default submission
         //
@@ -147,7 +151,7 @@
                         .attr('data-bs-validator', validatorName)
                         .addClass('help-block')
                         .addClass(['col-', size, '-offset-', offset].join(''))
-                        .addClass(['col-', size, '-', 12 - offset].join(''))
+                        .addClass(['col-', size, '-', this.options.columns - offset].join(''))
                         .appendTo($parent);
                 }
             }

File diff suppressed because it is too large
+ 1 - 1
dist/js/bootstrapValidator.min.js


+ 5 - 1
src/js/bootstrapValidator.js

@@ -33,6 +33,10 @@
         // Default invalid message
         message: 'This value is not valid',
 
+        // The number of grid columns
+        // Change it if you use custom grid with different number of columns
+        columns: 12,
+
         // The custom submit handler
         // It will prevent the form from the default submission
         //
@@ -146,7 +150,7 @@
                         .attr('data-bs-validator', validatorName)
                         .addClass('help-block')
                         .addClass(['col-', size, '-offset-', offset].join(''))
-                        .addClass(['col-', size, '-', 12 - offset].join(''))
+                        .addClass(['col-', size, '-', this.options.columns - offset].join(''))
                         .appendTo($parent);
                 }
             }