Browse Source

#89: ```submitHandler``` or default submission isn't called after ```remote``` validation completes

nghuuphuoc 11 years ago
parent
commit
47f162a9dc

+ 6 - 1
CHANGELOG.md

@@ -12,9 +12,14 @@ __New features__:
 * Add ```bower.json``` file
 * [#3, #92: Support more form controls on the same row](https://github.com/nghuuphuoc/bootstrapvalidator/issues/92)
 
+__Changes__:
+
+* Remove the ```columns``` option
+
 __Fixes__:
 
-* [#82, #84: The error/success messages aren't shown if the form field doesn't have label](https://github.com/nghuuphuoc/bootstrapvalidator/issues/82)
+* [#82, #84: The error messages aren't shown if the form field doesn't have label](https://github.com/nghuuphuoc/bootstrapvalidator/issues/82)
+* [#89: ```submitHandler``` or default submission isn't called after ```remote``` validation completes](https://github.com/nghuuphuoc/bootstrapvalidator/issues/89)
 
 ## v0.3.0
 

+ 10 - 1
demo/submitHandler.html

@@ -60,11 +60,16 @@
     $(document).ready(function() {
         $('#defaultForm').bootstrapValidator({
             message: 'This value is not valid',
+            live: 'disabled',
+            feedbackIcons: {
+                valid: 'glyphicon glyphicon-ok',
+                invalid: 'glyphicon glyphicon-remove',
+                validating: 'glyphicon glyphicon-refresh'
+            },
             submitHandler: function(validator, form, submitButton) {
                 // validator is the BootstrapValidator instance
                 // form is the jQuery object present the current form
                 form.find('.alert').html('Thanks for signing up. Now you can sign in as ' + validator.getFieldElements('username').val()).show();
-                //form.submit();
             },
             fields: {
                 username: {
@@ -78,6 +83,10 @@
                             max: 30,
                             message: 'The username must be more than 6 and less than 30 characters long'
                         },
+                        remote: {
+                            url: 'remote.php',
+                            message: 'The username is not available'
+                        },
                         regexp: {
                             regexp: /^[a-zA-Z0-9_\.]+$/,
                             message: 'The username can only consist of alphabetical, number, dot and underscore'

+ 4 - 4
dist/js/bootstrapValidator.js

@@ -36,10 +36,6 @@
         // 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,
-
         // Shows ok/error/loading icons based on the field validity.
         // This feature requires Bootstrap v3.1.0 or later (http://getbootstrap.com/css/#forms-control-validation).
         // Since Bootstrap doesn't provide any methods to know its version, this option cannot be on/off automatically.
@@ -354,6 +350,10 @@
                         delete that.dfds[field][v];
                         isValid ? that.updateStatus($field, v, that.STATUS_VALID)
                                 : that.updateStatus($field, v, that.STATUS_INVALID);
+
+                        if (isValid && that.options.live == 'disabled') {
+                            that._submit();
+                        }
                     });
                 } else if ('boolean' == typeof validateResult) {
                     validateResult ? this.updateStatus($field, validatorName, this.STATUS_VALID)

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


+ 4 - 0
src/js/bootstrapValidator.js

@@ -349,6 +349,10 @@
                         delete that.dfds[field][v];
                         isValid ? that.updateStatus($field, v, that.STATUS_VALID)
                                 : that.updateStatus($field, v, that.STATUS_INVALID);
+
+                        if (isValid && that.options.live == 'disabled') {
+                            that._submit();
+                        }
                     });
                 } else if ('boolean' == typeof validateResult) {
                     validateResult ? this.updateStatus($field, validatorName, this.STATUS_VALID)