Browse Source

#375: Don't submit form when the callback validator completes and the submit button isn't clicked

phuoc 11 years ago
parent
commit
2204056cf4

+ 1 - 0
CHANGELOG.md

@@ -68,6 +68,7 @@ __Bug Fixes__
 * [#315](https://github.com/nghuuphuoc/bootstrapvalidator/issues/315): The [cvv validator](http://bootstrapvalidator.com/validators/cvv/) doesn't work on IE 8
 * [#315](https://github.com/nghuuphuoc/bootstrapvalidator/issues/315): The [cvv validator](http://bootstrapvalidator.com/validators/cvv/) doesn't work on IE 8
 * [#325](https://github.com/nghuuphuoc/bootstrapvalidator/issues/325): The [```threshold``` option](http://bootstrapvalidator.com/settings/#threshold) doesn't work on IE 8
 * [#325](https://github.com/nghuuphuoc/bootstrapvalidator/issues/325): The [```threshold``` option](http://bootstrapvalidator.com/settings/#threshold) doesn't work on IE 8
 * [#358](https://github.com/nghuuphuoc/bootstrapvalidator/issues/358): The [zipCode validator](http://bootstrapvalidator.com/validators/zipCode/) doesn't work for Canadian zip code
 * [#358](https://github.com/nghuuphuoc/bootstrapvalidator/issues/358): The [zipCode validator](http://bootstrapvalidator.com/validators/zipCode/) doesn't work for Canadian zip code
+* [#375](https://github.com/nghuuphuoc/bootstrapvalidator/issues/375): Don't submit form when the [callback validator](http://bootstrapvalidator.com/validators/callback/) completes and the submit button isn't clicked
 * [#377](https://github.com/nghuuphuoc/bootstrapvalidator/issues/377): The [id](http://bootstrapvalidator.com/validators/id/), [vat](http://bootstrapvalidator.com/validators/vat/) validators should return ```false``` if the country code is not supported
 * [#377](https://github.com/nghuuphuoc/bootstrapvalidator/issues/377): The [id](http://bootstrapvalidator.com/validators/id/), [vat](http://bootstrapvalidator.com/validators/vat/) validators should return ```false``` if the country code is not supported
 * [#389](https://github.com/nghuuphuoc/bootstrapvalidator/issues/389): When using multiple forms with HTML attributes on the same page, the plugin options will be the same as the last one
 * [#389](https://github.com/nghuuphuoc/bootstrapvalidator/issues/389): When using multiple forms with HTML attributes on the same page, the plugin options will be the same as the last one
 * [#401](https://github.com/nghuuphuoc/bootstrapvalidator/issues/401): [stringLength validator](http://bootstrapvalidator.com/validators/stringLength/) allows spaces after max length
 * [#401](https://github.com/nghuuphuoc/bootstrapvalidator/issues/401): [stringLength validator](http://bootstrapvalidator.com/validators/stringLength/) allows spaces after max length

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

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

+ 6 - 3
dist/js/bootstrapValidator.js

@@ -2,7 +2,7 @@
  * BootstrapValidator (http://bootstrapvalidator.com)
  * BootstrapValidator (http://bootstrapvalidator.com)
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  *
  *
- * @version     v0.5.0-dev, built on 2014-07-06 9:40:56 PM
+ * @version     v0.5.0-dev, built on 2014-07-06 10:02:44 PM
  * @author      https://twitter.com/nghuuphuoc
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT
  * @license     MIT
@@ -254,8 +254,6 @@
 
 
                 // Whenever the user change the field value, mark it as not validated yet
                 // Whenever the user change the field value, mark it as not validated yet
                 $field.off(events).on(events, function() {
                 $field.off(events).on(events, function() {
-                    // Reset the flag
-                    that._submitIfValid = false;
                     that.updateStatus($(this), that.STATUS_NOT_VALIDATED);
                     that.updateStatus($(this), that.STATUS_NOT_VALIDATED);
                 });
                 });
 
 
@@ -828,6 +826,11 @@
                     break;
                     break;
             }
             }
 
 
+            if (status === this.STATUS_NOT_VALIDATED) {
+                // Reset the flag
+                this._submitIfValid = false;
+            }
+
             var that  = this,
             var that  = this,
                 type  = fields.attr('type'),
                 type  = fields.attr('type'),
                 group = this.options.fields[field].group || this.options.group,
                 group = this.options.fields[field].group || this.options.group,

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


+ 5 - 2
src/js/bootstrapValidator.js

@@ -253,8 +253,6 @@
 
 
                 // Whenever the user change the field value, mark it as not validated yet
                 // Whenever the user change the field value, mark it as not validated yet
                 $field.off(events).on(events, function() {
                 $field.off(events).on(events, function() {
-                    // Reset the flag
-                    that._submitIfValid = false;
                     that.updateStatus($(this), that.STATUS_NOT_VALIDATED);
                     that.updateStatus($(this), that.STATUS_NOT_VALIDATED);
                 });
                 });
 
 
@@ -827,6 +825,11 @@
                     break;
                     break;
             }
             }
 
 
+            if (status === this.STATUS_NOT_VALIDATED) {
+                // Reset the flag
+                this._submitIfValid = false;
+            }
+
             var that  = this,
             var that  = this,
                 type  = fields.attr('type'),
                 type  = fields.attr('type'),
                 group = this.options.fields[field].group || this.options.group,
                 group = this.options.fields[field].group || this.options.group,