Sorry, I have not updated this plugin in a few years, but ...
jquery.limitkeypress now works with IE9 +, there was a problem with selecting selection.
IE11 killed support for its .selection document, but they retained document.setSelectionRange, which I used to check which browser is used ...
IE9 included document.selectionStart and document.selectionEnd, so now I check which version of IE browser is used in the browser ...
I added this to check the version of IE:
var ie = (function(){ var undef, v = 3, div = document.createElement('div'), all = div.getElementsByTagName('i'); while ( div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->', all[0] ); return v > 4 ? v : undef; }());
So, my selection functions now look like this:
function getSelectionStart(o) { if (ie < 9) { var r = document.selection.createRange().duplicate() r.moveEnd('character', o.value.length) if (r.text == '') return o.value.length return o.value.lastIndexOf(r.text) } else return o.selectionStart } function getSelectionEnd(o) { if (ie < 9) { var r = document.selection.createRange().duplicate() r.moveStart('character', -o.value.length) return r.text.length } else return o.selectionEnd }
source share