nghuuphuoc 11 years ago
parent
commit
6ba82de2f2
4 changed files with 21 additions and 6 deletions
  1. 1 0
      CHANGELOG.md
  2. 9 2
      dist/js/bootstrapValidator.js
  3. 2 2
      dist/js/bootstrapValidator.min.js
  4. 9 2
      src/js/bootstrapValidator.js

+ 1 - 0
CHANGELOG.md

@@ -8,6 +8,7 @@
 * [#201](https://github.com/nghuuphuoc/bootstrapvalidator/issues/201): ```choice``` validator supports select element
 * [#202](https://github.com/nghuuphuoc/bootstrapvalidator/issues/202): Activate tab containing the first invalid field
 * [#205](https://github.com/nghuuphuoc/bootstrapvalidator/issues/205): Plugin method invocation
+* [#207](https://github.com/nghuuphuoc/bootstrapvalidator/issues/207): IE8 error
 * [#209](https://github.com/nghuuphuoc/bootstrapvalidator/issues/209): The ```excluded: ':disabled'``` setting does not work on IE 8, thanks to [@adgrafik](https://github.com/adgrafik)
 * [#210](https://github.com/nghuuphuoc/bootstrapvalidator/issues/210): ```isbn``` validator accepts letters and special characters
 

+ 9 - 2
dist/js/bootstrapValidator.js

@@ -26,9 +26,16 @@
         // Determine the event that is fired when user change the field value
         // Most modern browsers supports input event except IE 7, 8.
         // IE 9 supports input event but the event is still not fired if I press the backspace key.
-        // In that case I will use the keydown event
+        // Get IE version
+        // https://gist.github.com/padolsey/527683/#comment-7595
+        var ieVersion = (function() {
+            var v = 3, div = document.createElement('div'), a = div.all || [];
+            while (div.innerHTML = '<!--[if gt IE '+(++v)+']><br><![endif]-->', a[0]);
+            return v > 4 ? v : !v;
+        }());
+
         var el = document.createElement('div');
-        this._changeEvent = ('oninput' in el) ? 'input' : 'keydown';
+        this._changeEvent = (ieVersion === 9 || !('oninput' in el)) ? 'keyup' : 'input';
 
         // The flag to indicate that the form is ready to submit when a remote/callback validator returns
         this._submitIfValid = null;

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


+ 9 - 2
src/js/bootstrapValidator.js

@@ -25,9 +25,16 @@
         // Determine the event that is fired when user change the field value
         // Most modern browsers supports input event except IE 7, 8.
         // IE 9 supports input event but the event is still not fired if I press the backspace key.
-        // In that case I will use the keydown event
+        // Get IE version
+        // https://gist.github.com/padolsey/527683/#comment-7595
+        var ieVersion = (function() {
+            var v = 3, div = document.createElement('div'), a = div.all || [];
+            while (div.innerHTML = '<!--[if gt IE '+(++v)+']><br><![endif]-->', a[0]);
+            return v > 4 ? v : !v;
+        }());
+
         var el = document.createElement('div');
-        this._changeEvent = ('oninput' in el) ? 'input' : 'keydown';
+        this._changeEvent = (ieVersion === 9 || !('oninput' in el)) ? 'keyup' : 'input';
 
         // The flag to indicate that the form is ready to submit when a remote/callback validator returns
         this._submitIfValid = null;