浏览代码

#832: The form won't be validated if the submit button contains a HTML tag

phuoc 11 年之前
父节点
当前提交
9a5207ebaf

+ 1 - 0
CHANGELOG.md

@@ -48,6 +48,7 @@ __Bug Fixes__
 The tooltip/popover is shown automatically when the field gets the focus, thanks to [@leedorian](https://github.com/leedorian)
 * [#797](https://github.com/nghuuphuoc/bootstrapvalidator/issues/797), [#799](https://github.com/nghuuphuoc/bootstrapvalidator/pull/799): Can't validate ipv4 and ipv6 at the same time. Add ip validator test suite, thanks to [@Arkni](https://github.com/Arkni)
 * [#816](https://github.com/nghuuphuoc/bootstrapvalidator/pull/816): Fix Russian [VAT](http://bootstrapvalidator.com/validators/vat/) number validator, thanks to [@stepin](https://github.com/stepin)
+* [#832](https://github.com/nghuuphuoc/bootstrapvalidator/issues/832): The form won't be validated if the submit button contains a HTML tag
 
 __Document__
 * [#709](https://github.com/nghuuphuoc/bootstrapvalidator/issues/709), [#715](https://github.com/nghuuphuoc/bootstrapvalidator/pull/715): Add [Bootstrap Select](http://bootstrapvalidator.com/examples/bootstrap-select/) and [Select2](http://bootstrapvalidator.com/examples/select2/) examples, thanks to [@Arkni](https://github.com/Arkni)

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

@@ -2,7 +2,7 @@
  * BootstrapValidator (http://bootstrapvalidator.com)
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  *
- * @version     v0.5.2-dev, built on 2014-09-12 8:40:58 AM
+ * @version     v0.5.2-dev, built on 2014-09-13 2:51:29 PM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT

+ 5 - 2
dist/js/bootstrapValidator.js

@@ -2,7 +2,7 @@
  * BootstrapValidator (http://bootstrapvalidator.com)
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  *
- * @version     v0.5.2-dev, built on 2014-09-12 8:40:58 AM
+ * @version     v0.5.2-dev, built on 2014-09-13 2:51:29 PM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT
@@ -131,9 +131,12 @@ if (typeof jQuery === 'undefined') {
                 .on('click.bv', '[type="submit"]', function(e) {
                     // #746: Check if the button click handler returns false
                     if (!e.isDefaultPrevented()) {
+                        var $target = $(e.target),
+                            // The button might contain HTML tag
+                            $button = $target.is('[type="submit"]') ? $target.eq(0) : $target.parent('[type="submit"]').eq(0);
+
                         // Don't perform validation when clicking on the submit button/input
                         // which aren't defined by the 'submitButtons' option
-                        var $button = $(e.target).eq(0);
                         if (that.options.submitButtons && !$button.is(that.options.submitButtons) && !$button.is(that.$hiddenButton)) {
                             that.$form.off('submit.bv').submit();
                         }

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


+ 4 - 1
src/js/bootstrapValidator.js

@@ -131,9 +131,12 @@ if (typeof jQuery === 'undefined') {
                 .on('click.bv', '[type="submit"]', function(e) {
                     // #746: Check if the button click handler returns false
                     if (!e.isDefaultPrevented()) {
+                        var $target = $(e.target),
+                            // The button might contain HTML tag
+                            $button = $target.is('[type="submit"]') ? $target.eq(0) : $target.parent('[type="submit"]').eq(0);
+
                         // Don't perform validation when clicking on the submit button/input
                         // which aren't defined by the 'submitButtons' option
-                        var $button = $(e.target).eq(0);
                         if (that.options.submitButtons && !$button.is(that.options.submitButtons) && !$button.is(that.$hiddenButton)) {
                             that.$form.off('submit.bv').submit();
                         }