Browse Source

#991: The field is validated only one time when setting trigger: 'blur', container: 'tooltip'

Phuoc Nguyen 11 years ago
parent
commit
0b4c6c6656

+ 25 - 2
demo/tooltip.html

@@ -21,15 +21,22 @@
 
                     <form id="defaultForm" method="post" class="form-horizontal" action="target.php">
                         <div class="form-group">
-                            <label class="col-sm-3 control-label">Full name</label>
+                            <label class="col-sm-3 control-label">First name</label>
                             <div class="col-sm-4">
                                 <input type="text" class="form-control" name="firstName" placeholder="First name" />
                             </div>
                         </div>
 
                         <div class="form-group">
+                            <label class="col-sm-3 control-label">Last name</label>
+                            <div class="col-sm-4">
+                                <input type="text" class="form-control" name="lastName" placeholder="Last name" />
+                            </div>
+                        </div>
+
+                        <div class="form-group">
                             <div class="col-sm-9 col-sm-offset-3">
-                                <button type="submit" class="btn btn-primary">Sign up</button>
+                                <button type="submit" class="btn btn-primary">Validate</button>
                             </div>
                         </div>
                     </form>
@@ -42,6 +49,7 @@
 $(document).ready(function() {
     $('#defaultForm').bootstrapValidator({
         container: 'tooltip',
+//        trigger: 'blur',
         feedbackIcons: {
             valid: 'glyphicon glyphicon-ok',
             invalid: 'glyphicon glyphicon-remove',
@@ -64,6 +72,21 @@ $(document).ready(function() {
                         message: 'The first name must consist of a-z, A-Z characters only'
                     }
                 }
+            },
+            lastName: {
+                validators: {
+                    stringLength: {
+                        min: 4,
+                        message: 'The last name must be more than 5 characters'
+                    },
+                    notEmpty: {
+                        message: 'The last name is required'
+                    },
+                    regexp: {
+                        regexp: /^[a-z]+$/i,
+                        message: 'The last name must consist of a-z, A-Z characters only'
+                    }
+                }
             }
         }
     });

+ 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.3-dev, built on 2014-10-20 2:17:50 PM
+ * @version     v0.5.3-dev, built on 2014-10-20 3:33:28 PM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT

+ 5 - 5
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.3-dev, built on 2014-10-20 2:17:51 PM
+ * @version     v0.5.3-dev, built on 2014-10-20 3:33:28 PM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT
@@ -368,8 +368,8 @@ if (typeof jQuery === 'undefined') {
                     if (container) {
                         $field
                             // Show tooltip/popover message when field gets focus
-                            .off('focus.bv')
-                            .on('focus.bv', function() {
+                            .off('focus.container.bv')
+                            .on('focus.container.bv', function() {
                                 switch (container) {
                                     case 'tooltip':
                                         $icon.tooltip('show');
@@ -382,8 +382,8 @@ if (typeof jQuery === 'undefined') {
                                 }
                             })
                             // and hide them when losing focus
-                            .off('blur.bv')
-                            .on('blur.bv', function() {
+                            .off('blur.container.bv')
+                            .on('blur.container.bv', function() {
                                 switch (container) {
                                     case 'tooltip':
                                         $icon.tooltip('hide');

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


+ 4 - 4
src/js/bootstrapValidator.js

@@ -368,8 +368,8 @@ if (typeof jQuery === 'undefined') {
                     if (container) {
                         $field
                             // Show tooltip/popover message when field gets focus
-                            .off('focus.bv')
-                            .on('focus.bv', function() {
+                            .off('focus.container.bv')
+                            .on('focus.container.bv', function() {
                                 switch (container) {
                                     case 'tooltip':
                                         $icon.tooltip('show');
@@ -382,8 +382,8 @@ if (typeof jQuery === 'undefined') {
                                 }
                             })
                             // and hide them when losing focus
-                            .off('blur.bv')
-                            .on('blur.bv', function() {
+                            .off('blur.container.bv')
+                            .on('blur.container.bv', function() {
                                 switch (container) {
                                     case 'tooltip':
                                         $icon.tooltip('hide');