code: function getValueLengthThroughSelection(input) {
              // only do this on opera, since it'll mess up the caret position
              // and break Firefox functionality
              if (!/Opera/i.test(navigator.userAgent)) {
                return 0;
              }
  
              input.focus();
              document.execCommand("selectAll");
              var focusNode = window.getSelection().focusNode;
              return (focusNode || {}).selectionStart || 0;
            }
docs: HACK: Opera 12 won't give us a wrong validity status although the input is invalid we can select the whole text and check the selection size Congratulations to IE 11 for doing the same but not returning the selection.