浏览代码

#451: Validation of numeric fields with decimal steps, thanks to @Azuka

phuoc 11 年之前
父节点
当前提交
234f07e964

+ 1 - 0
CHANGELOG.md

@@ -53,6 +53,7 @@ __Improvements__
 * [#431](https://github.com/nghuuphuoc/bootstrapvalidator/issues/431): Add built time to the build file
 * [#432](https://github.com/nghuuphuoc/bootstrapvalidator/issues/432): Define the callback via ```data-bv-callback-callback``` attribute
 * [#447](https://github.com/nghuuphuoc/bootstrapvalidator/pull/447): [zipCode validator](http://bootstrapvalidator.com/validators/zipCode/) allow to set the country code via another field or callback, thanks to [@AlaskanShade](https://github.com/AlaskanShade)
+* [#451](https://github.com/nghuuphuoc/bootstrapvalidator/pull/451): Validation of numeric fields with decimal steps, thanks to [@Azuka](https://github.com/Azuka)
 * [#456](https://github.com/nghuuphuoc/bootstrapvalidator/issues/456): Adjust the feedback icon position for ```.input-group``` element
 * [#465](https://github.com/nghuuphuoc/bootstrapvalidator/issues/465): Support dynamic message
 

+ 40 - 0
CONTRIBUTORS.md

@@ -0,0 +1,40 @@
+# Contributors
+===
+
+* [@aca02djr](https://github.com/aca02djr)
+* [@adgrafik](https://github.com/adgrafik)
+* [@AlaskanShade](https://github.com/AlaskanShade)
+* [@alavers](https://github.com/alavers)
+* [@Azuka](https://github.com/Azuka)
+* [@easonhan007](https://github.com/easonhan007)
+* [@emilchristensen](https://github.com/emilchristensen)
+* [@ericnakagawa](https://github.com/ericnakagawa)
+* [@evilchili](https://github.com/evilchili)
+* [@Francismori7](https://github.com/Francismori7)
+* [@gercheq](https://github.com/gercheq)
+* [@henningda](https://github.com/henningda)
+* [@ikanedo](https://github.com/ikanedo)
+* [@iplus](https://github.com/iplus)
+* [@jcnmulio](https://github.com/jcnmulio)
+* [@jjshoe](https://github.com/jjshoe)
+* [@johanronn77](https://github.com/johanronn77)
+* [@jswale](https://github.com/jswale)
+* [@jzhang6](https://github.com/jzhang6)
+* [@khangvm53](https://github.com/khangvm53)
+* [@kristian-puccio](https://github.com/kristian-puccio)
+* [@lloydde](https://github.com/lloydde)
+* [@manish-in-java](https://github.com/manish-in-java)
+* [@MartinDevillers](https://github.com/MartinDevillers)
+* [@mike1e](https://github.com/mike1e)
+* [@MrC0mm0n](https://github.com/MrC0mm0n)
+* [@mrpollo](https://github.com/mrpollo)
+* [@narutosanjiv](https://github.com/narutosanjiv)
+* [@nathanrosspowell](https://github.com/nathanrosspowell)
+* [@patmoore](https://github.com/patmoore)
+* [@phillprice](https://github.com/phillprice)
+* [@smeagol74](https://github.com/smeagol74)
+* [@thisisclement](https://github.com/thisisclement)
+* [@tiagofontella](https://github.com/tiagofontella)
+* [@tomByrer](https://github.com/tomByrer)
+* [@vaz](https://github.com/vaz)
+* ... might be you! Let's [fork](https://github.com/nghuuphuoc/bootstrapvalidator/fork) and pull a request!

+ 1 - 42
README.md

@@ -105,48 +105,7 @@ The __BootstrapValidator__ plugin is written by Nguyen Huu Phuoc, aka @nghuuphuo
 * [http://twitter.com/nghuuphuoc](http://twitter.com/nghuuphuoc)
 * [http://github.com/nghuuphuoc](http://github.com/nghuuphuoc)
 
-Big thanks to the contributors:
-
-* [@aca02djr](https://github.com/aca02djr)
-* [@adgrafik](https://github.com/adgrafik)
-* [@AlaskanShade](https://github.com/AlaskanShade)
-* [@alavers](https://github.com/alavers)
-* [@easonhan007](https://github.com/easonhan007)
-* [@emilchristensen](https://github.com/emilchristensen)
-* [@ericnakagawa](https://github.com/ericnakagawa)
-* [@evilchili](https://github.com/evilchili)
-* [@Francismori7](https://github.com/Francismori7)
-* [@gercheq](https://github.com/gercheq)
-* [@henningda](https://github.com/henningda)
-* [@ikanedo](https://github.com/ikanedo)
-* [@iplus](https://github.com/iplus)
-* [@jcnmulio](https://github.com/jcnmulio)
-* [@jjshoe](https://github.com/jjshoe)
-* [@johanronn77](https://github.com/johanronn77)
-* [@jswale](https://github.com/jswale)
-* [@jzhang6](https://github.com/jzhang6)
-* [@khangvm53](https://github.com/khangvm53)
-* [@kristian-puccio](https://github.com/kristian-puccio)
-* [@lloydde](https://github.com/lloydde)
-* [@manish-in-java](https://github.com/manish-in-java)
-* [@MartinDevillers](https://github.com/MartinDevillers)
-* [@mike1e](https://github.com/mike1e)
-* [@MrC0mm0n](https://github.com/MrC0mm0n)
-* [@mrpollo](https://github.com/mrpollo)
-* [@narutosanjiv](https://github.com/narutosanjiv)
-* [@nathanrosspowell](https://github.com/nathanrosspowell)
-* [@patmoore](https://github.com/patmoore)
-* [@phillprice](https://github.com/phillprice)
-* [@smeagol74](https://github.com/smeagol74)
-* [@thisisclement](https://github.com/thisisclement)
-* [@tiagofontella](https://github.com/tiagofontella)
-* [@tomByrer](https://github.com/tomByrer)
-* [@vaz](https://github.com/vaz)
-* ... might be you! Let's [fork](https://github.com/nghuuphuoc/bootstrapvalidator/fork) and pull a request!
-
-> If you submit new RegEx, please build it using [RegExr.com](http://regexr.com/), add several tests that pass and fail there,
-> and include the "share" link in your JS as a ```// ``` comment.
-> For example: ```// Test: http://regexr.com/38mqi```
+Big thanks to the [contributors](CONTRIBUTORS.md).
 
 ## License
 

+ 1 - 1
dist/css/bootstrapValidator.min.css

@@ -2,7 +2,7 @@
  * BootstrapValidator (http://bootstrapvalidator.com)
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  *
- * @version     v0.5.0-dev, built on 2014-07-09 9:40:22 AM
+ * @version     v0.5.0-dev, built on 2014-07-09 10:07:03 AM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT

+ 6 - 2
dist/js/bootstrapValidator.js

@@ -2,7 +2,7 @@
  * BootstrapValidator (http://bootstrapvalidator.com)
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  *
- * @version     v0.5.0-dev, built on 2014-07-09 9:40:22 AM
+ * @version     v0.5.0-dev, built on 2014-07-09 10:07:03 AM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT
@@ -3905,7 +3905,7 @@
 
     $.fn.bootstrapValidator.validators.integer = {
         enableByHtml5: function($field) {
-            return ('number' === $field.attr('type'));
+            return ('number' === $field.attr('type')) && ($field.attr('step') === undefined || $field.attr('step') % 1 === 0);
         },
 
         /**
@@ -4353,6 +4353,10 @@
             separator: 'separator'
         },
 
+        enableByHtml5: function($field) {
+            return ('number' === $field.attr('type')) && ($field.attr('step') !== undefined) && ($field.attr('step') % 1 !== 0);
+        },
+
         /**
          * Validate decimal number
          *

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


+ 1 - 1
src/js/validator/integer.js

@@ -5,7 +5,7 @@
 
     $.fn.bootstrapValidator.validators.integer = {
         enableByHtml5: function($field) {
-            return ('number' == $field.attr('type') && ( typeof($field.prop('step')) == 'undefined' || $field.prop('step') % 1 === 0  ));
+            return ('number' === $field.attr('type')) && ($field.attr('step') === undefined || $field.attr('step') % 1 === 0);
         },
 
         /**

+ 4 - 3
src/js/validator/numeric.js

@@ -4,14 +4,15 @@
     });
 
     $.fn.bootstrapValidator.validators.numeric = {
-        enableByHtml5: function($field) {
-            return ('number' == $field.attr('type') && ( typeof($field.prop('step')) !== 'undefined' && $field.prop('step') % 1 !== 0  ));
-        },
         html5Attributes: {
             message: 'message',
             separator: 'separator'
         },
 
+        enableByHtml5: function($field) {
+            return ('number' === $field.attr('type')) && ($field.attr('step') !== undefined) && ($field.attr('step') % 1 !== 0);
+        },
+
         /**
          * Validate decimal number
          *