Browse Source

update validator when click submit button

khangvu 12 years ago
parent
commit
76d413fabf
3 changed files with 11 additions and 5 deletions
  1. 5 2
      dist/js/bootstrapValidator.js
  2. 1 1
      dist/js/bootstrapValidator.min.js
  3. 5 2
      src/js/bootstrapValidator.js

+ 5 - 2
dist/js/bootstrapValidator.js

@@ -15,7 +15,7 @@
 
         this.invalidFields      = {};
         this.xhrRequests        = {};
-        this.numPendingRequests = 0;
+        this.numPendingRequests = null;
 
         this._init();
     };
@@ -47,7 +47,7 @@
                     that.formSubmited = true;
                     if (that.options.fields) {
                         for (var field in that.options.fields) {
-                            if(that.numPendingRequests > 0){
+                            if(that.numPendingRequests > 0 || that.numPendingRequests == null ){
                                 that.validateField(field);
                             }
                         }
@@ -164,6 +164,9 @@
 
         startRequest: function($field, validatorName, xhr) {
             var field = $field.attr('name');
+            if(this.numPendingRequests == null){
+                this.numPendingRequests = 0;
+            }
             this.numPendingRequests++;
             // Abort the previous request
             if (!this.xhrRequests[field]) {

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


+ 5 - 2
src/js/bootstrapValidator.js

@@ -15,7 +15,7 @@
 
         this.invalidFields      = {};
         this.xhrRequests        = {};
-        this.numPendingRequests = 0;
+        this.numPendingRequests = null;
 
         this._init();
     };
@@ -47,7 +47,7 @@
                     that.formSubmited = true;
                     if (that.options.fields) {
                         for (var field in that.options.fields) {
-                            if(that.numPendingRequests > 0){
+                            if(that.numPendingRequests > 0 || that.numPendingRequests == null ){
                                 that.validateField(field);
                             }
                         }
@@ -164,6 +164,9 @@
 
         startRequest: function($field, validatorName, xhr) {
             var field = $field.attr('name');
+            if(this.numPendingRequests == null){
+                this.numPendingRequests = 0;
+            }
             this.numPendingRequests++;
             // Abort the previous request
             if (!this.xhrRequests[field]) {