浏览代码

Merge branch 'master' of https://github.com/mgibas/bootstrapvalidator into mgibas-master

Conflicts:
	dist/css/bootstrapValidator.min.css
	dist/js/bootstrapValidator.js
	dist/js/bootstrapValidator.min.js
Phuoc Nguyen 11 年之前
父节点
当前提交
ed8af1d0f3
共有 6 个文件被更改,包括 52 次插入1 次删除
  1. 2 1
      .gitignore
  2. 3 0
      src/js/validator/greaterThan.js
  3. 3 0
      src/js/validator/lessThan.js
  4. 22 0
      test/spec.js
  5. 11 0
      test/spec/validator/greaterThan.js
  6. 11 0
      test/spec/validator/lessThan.js

+ 2 - 1
.gitignore

@@ -1,3 +1,4 @@
 .idea
 _gh_pages
-node_modules
+node_modules
+bower_components

+ 3 - 0
src/js/validator/greaterThan.js

@@ -44,6 +44,9 @@
             if (value === '') {
                 return true;
             }
+            if (value.indexOf(',') > -1){
+                value = value.replace(',', '.');
+            }
             if (!$.isNumeric(value)) {
                 return false;
             }

+ 3 - 0
src/js/validator/lessThan.js

@@ -44,6 +44,9 @@
             if (value === '') {
                 return true;
             }
+            if (value.indexOf(',') > -1){
+                value = value.replace(',', '.');
+            }
             if (!$.isNumeric(value)) {
                 return false;
             }

+ 22 - 0
test/spec.js

@@ -4199,6 +4199,17 @@ describe('greaterThan', function() {
         expect(this.bv.isValid()).toBeTruthy();
     });
 
+    it('value with coma separator', function() {
+        this.$age.val('10,4');
+        this.bv.validate();
+        expect(this.bv.isValid()).toEqual(false);
+
+        this.bv.resetForm();
+        this.$age.val('18,678');
+        this.bv.validate();
+        expect(this.bv.isValid()).toBeTruthy();
+    });
+
     it('compare to other field', function() {
         this.$age.attr('data-bv-greaterthan-value', 'minAge');
         this.bv.destroy();
@@ -5847,6 +5858,17 @@ describe('lessThan', function() {
         expect(this.bv.isValid()).toEqual(false);
     });
 
+    it('value with coma separator', function() {
+        this.$age.val('120,2234');
+        this.bv.validate();
+        expect(this.bv.isValid()).toEqual(false);
+
+        this.bv.resetForm();
+        this.$age.val('30,2234');
+        this.bv.validate();
+        expect(this.bv.isValid()).toBeTruthy();
+    });
+
     it('compare to value', function() {
         this.$age.val(120);
         this.bv.validate();

+ 11 - 0
test/spec/validator/greaterThan.js

@@ -56,6 +56,17 @@ describe('greaterThan', function() {
         expect(this.bv.isValid()).toBeTruthy();
     });
 
+    it('value with coma separator', function() {
+        this.$age.val('10,4');
+        this.bv.validate();
+        expect(this.bv.isValid()).toEqual(false);
+
+        this.bv.resetForm();
+        this.$age.val('18,678');
+        this.bv.validate();
+        expect(this.bv.isValid()).toBeTruthy();
+    });
+
     it('compare to other field', function() {
         this.$age.attr('data-bv-greaterthan-value', 'minAge');
         this.bv.destroy();

+ 11 - 0
test/spec/validator/lessThan.js

@@ -45,6 +45,17 @@ describe('lessThan', function() {
         expect(this.bv.isValid()).toEqual(false);
     });
 
+    it('value with coma separator', function() {
+        this.$age.val('120,2234');
+        this.bv.validate();
+        expect(this.bv.isValid()).toEqual(false);
+
+        this.bv.resetForm();
+        this.$age.val('30,2234');
+        this.bv.validate();
+        expect(this.bv.isValid()).toBeTruthy();
+    });
+
     it('compare to value', function() {
         this.$age.val(120);
         this.bv.validate();