浏览代码

Submit form when all validators are completed and the form is valid

nghuuphuoc 11 年之前
父节点
当前提交
b6014376aa
共有 6 个文件被更改,包括 129 次插入54 次删除
  1. 1 0
      CHANGELOG.md
  2. 113 42
      demo/index.html
  3. 4 3
      dist/css/bootstrapValidator.min.css
  4. 5 4
      dist/js/bootstrapValidator.js
  5. 5 4
      dist/js/bootstrapValidator.min.js
  6. 1 1
      src/js/bootstrapValidator.js

+ 1 - 0
CHANGELOG.md

@@ -4,6 +4,7 @@
 
 
 * [#44: Rewrite entirely using Deferred](https://github.com/nghuuphuoc/bootstrapvalidator/issues/44)
 * [#44: Rewrite entirely using Deferred](https://github.com/nghuuphuoc/bootstrapvalidator/issues/44)
 * [#71: Show all errors](https://github.com/nghuuphuoc/bootstrapvalidator/issues/71)
 * [#71: Show all errors](https://github.com/nghuuphuoc/bootstrapvalidator/issues/71)
+* [#51: Submit after submit doesn't work](https://github.com/nghuuphuoc/bootstrapvalidator/issues/51)
 * [#53: Fix notEmpty validator for radios and checkboxes](https://github.com/nghuuphuoc/bootstrapvalidator/issues/53)
 * [#53: Fix notEmpty validator for radios and checkboxes](https://github.com/nghuuphuoc/bootstrapvalidator/issues/53)
 * [#62: The callback validator passes wrong parameter](https://github.com/nghuuphuoc/bootstrapvalidator/issues/62)
 * [#62: The callback validator passes wrong parameter](https://github.com/nghuuphuoc/bootstrapvalidator/issues/62)
 * [#60: Update the installation guide](https://github.com/nghuuphuoc/bootstrapvalidator/pull/60)
 * [#60: Update the installation guide](https://github.com/nghuuphuoc/bootstrapvalidator/pull/60)

+ 113 - 42
demo/index.html

@@ -50,6 +50,58 @@
                         </div>
                         </div>
 
 
                         <div class="form-group">
                         <div class="form-group">
+                            <label class="col-lg-3 control-label">Gender</label>
+                            <div class="col-lg-9">
+                                <div class="radio">
+                                    <label>
+                                        <input type="radio" name="gender" value="male" /> Male
+                                    </label>
+                                </div>
+                                <div class="radio">
+                                    <label>
+                                        <input type="radio" name="gender" value="female" /> Female
+                                    </label>
+                                </div>
+                                <div class="radio">
+                                    <label>
+                                        <input type="radio" name="gender" value="other" /> Other
+                                    </label>
+                                </div>
+                            </div>
+                        </div>
+
+                        <div class="form-group">
+                            <label class="col-lg-3 control-label">Languages</label>
+                            <div class="col-lg-9">
+                                <div class="checkbox">
+                                    <label>
+                                        <input type="checkbox" name="languages[]" value="english" /> English
+                                    </label>
+                                </div>
+                                <div class="checkbox">
+                                    <label>
+                                        <input type="checkbox" name="languages[]" value="french" /> French
+                                    </label>
+                                </div>
+                                <div class="checkbox">
+                                    <label>
+                                        <input type="checkbox" name="languages[]" value="german" /> German
+                                    </label>
+                                </div>
+                                <div class="checkbox">
+                                    <label>
+                                        <input type="checkbox" name="languages[]" value="russian" /> Russian
+                                    </label>
+                                </div>
+                                <div class="checkbox">
+                                    <label>
+                                        <input type="checkbox" name="languages[]" value="other" /> Other
+                                    </label>
+                                </div>
+                            </div>
+                        </div>
+
+                        <div class="form-group">
                             <label class="col-lg-3 control-label" id="captchaOperation"></label>
                             <label class="col-lg-3 control-label" id="captchaOperation"></label>
                             <div class="col-lg-2">
                             <div class="col-lg-2">
                                 <input type="text" class="form-control" name="captcha" />
                                 <input type="text" class="form-control" name="captcha" />
@@ -77,6 +129,7 @@ $(document).ready(function() {
     $('#captchaOperation').html([randomNumber(1, 100), '+', randomNumber(1, 200), '='].join(' '));
     $('#captchaOperation').html([randomNumber(1, 100), '+', randomNumber(1, 200), '='].join(' '));
 
 
     $('#defaultForm').bootstrapValidator({
     $('#defaultForm').bootstrapValidator({
+//        live: 'submitted',
         message: 'This value is not valid',
         message: 'This value is not valid',
         fields: {
         fields: {
             username: {
             username: {
@@ -85,19 +138,23 @@ $(document).ready(function() {
                     notEmpty: {
                     notEmpty: {
                         message: 'The username is required and can\'t be empty'
                         message: 'The username is required and can\'t be empty'
                     },
                     },
-                    stringLength: {
-                        min: 6,
-                        max: 30,
-                        message: 'The username must be more than 6 and less than 30 characters long'
-                    },
-                    regexp: {
-                        regexp: /^[a-zA-Z0-9_\.]+$/,
-                        message: 'The username can only consist of alphabetical, number, dot and underscore'
+//                    stringLength: {
+//                        min: 6,
+//                        max: 30,
+//                        message: 'The username must be more than 6 and less than 30 characters long'
+//                    },
+//                    regexp: {
+//                        regexp: /^[a-zA-Z0-9_\.]+$/,
+//                        message: 'The username can only consist of alphabetical, number, dot and underscore'
+//                    },
+                    remote: {
+                        url: 'remote.php',
+                        message: 'The username is not available'
                     },
                     },
-                    different: {
-                        field: 'password',
-                        message: 'The username and password can\'t be the same as each other'
-                    }
+//                    different: {
+//                        field: 'password',
+//                        message: 'The username and password can\'t be the same as each other'
+//                    }
                 }
                 }
             },
             },
             email: {
             email: {
@@ -107,36 +164,50 @@ $(document).ready(function() {
                     }
                     }
                 }
                 }
             },
             },
-            password: {
-                validators: {
-                    notEmpty: {
-                        message: 'The password is required and can\'t be empty'
-                    },
-                    identical: {
-                        field: 'confirmPassword',
-                        message: 'The password and its confirm are not the same'
-                    },
-                    different: {
-                        field: 'username',
-                        message: 'The password can\'t be the same as username'
-                    }
-                }
-            },
-            confirmPassword: {
-                validators: {
-                    notEmpty: {
-                        message: 'The confirm password is required and can\'t be empty'
-                    },
-                    identical: {
-                        field: 'password',
-                        message: 'The password and its confirm are not the same'
-                    },
-                    different: {
-                        field: 'username',
-                        message: 'The password can\'t be the same as username'
-                    }
-                }
-            },
+//            password: {
+//                validators: {
+//                    notEmpty: {
+//                        message: 'The password is required and can\'t be empty'
+//                    },
+//                    identical: {
+//                        field: 'confirmPassword',
+//                        message: 'The password and its confirm are not the same'
+//                    },
+//                    different: {
+//                        field: 'username',
+//                        message: 'The password can\'t be the same as username'
+//                    }
+//                }
+//            },
+//            confirmPassword: {
+//                validators: {
+//                    notEmpty: {
+//                        message: 'The confirm password is required and can\'t be empty'
+//                    },
+//                    identical: {
+//                        field: 'password',
+//                        message: 'The password and its confirm are not the same'
+//                    },
+//                    different: {
+//                        field: 'username',
+//                        message: 'The password can\'t be the same as username'
+//                    }
+//                }
+//            },
+//            gender: {
+//                validators: {
+//                    notEmpty: {
+//                        message: 'The gender is required'
+//                    }
+//                }
+//            },
+//            'languages[]': {
+//                validators: {
+//                    notEmpty: {
+//                        message: 'Please specify at least one language you can speak'
+//                    }
+//                }
+//            },
             captcha: {
             captcha: {
                 validators: {
                 validators: {
                     callback: {
                     callback: {

+ 4 - 3
dist/css/bootstrapValidator.min.css

@@ -1,10 +1,11 @@
 /**
 /**
- * BootstrapValidator v0.3.0 (http://github.com/nghuuphuoc/bootstrapvalidator)
+ * BootstrapValidator (http://github.com/nghuuphuoc/bootstrapvalidator)
  *
  *
  * A jQuery plugin to validate form fields. Use with Bootstrap 3
  * A jQuery plugin to validate form fields. Use with Bootstrap 3
  *
  *
- * @author      Nguyen Huu Phuoc <phuoc@huuphuoc.me>
- * @copyright   (c) 2013 Nguyen Huu Phuoc
+ * @version     v0.3.0
+ * @author      https://twitter.com/nghuuphuoc
+ * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT
  * @license     MIT
  */
  */
 
 

+ 5 - 4
dist/js/bootstrapValidator.js

@@ -1,10 +1,11 @@
 /**
 /**
- * BootstrapValidator v0.3.0 (http://github.com/nghuuphuoc/bootstrapvalidator)
+ * BootstrapValidator (http://github.com/nghuuphuoc/bootstrapvalidator)
  *
  *
  * A jQuery plugin to validate form fields. Use with Bootstrap 3
  * A jQuery plugin to validate form fields. Use with Bootstrap 3
  *
  *
- * @author      Nguyen Huu Phuoc <phuoc@huuphuoc.me>
- * @copyright   (c) 2013 Nguyen Huu Phuoc
+ * @version     v0.3.0
+ * @author      https://twitter.com/nghuuphuoc
+ * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT
  * @license     MIT
  */
  */
 
 
@@ -200,7 +201,7 @@
                 this.options.submitHandler.call(this, this, this.$form);
                 this.options.submitHandler.call(this, this, this.$form);
             } else {
             } else {
                 // Submit form
                 // Submit form
-                //this.$form.off('submit.bootstrapValidator').submit();
+                this.$form.off('submit.bootstrapValidator').submit();
             }
             }
         },
         },
 
 

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


+ 1 - 1
src/js/bootstrapValidator.js

@@ -200,7 +200,7 @@
                 this.options.submitHandler.call(this, this, this.$form);
                 this.options.submitHandler.call(this, this, this.$form);
             } else {
             } else {
                 // Submit form
                 // Submit form
-                //this.$form.off('submit.bootstrapValidator').submit();
+                this.$form.off('submit.bootstrapValidator').submit();
             }
             }
         },
         },