code: function(elem) {
        // range {IE selection object}
        // iCaretPos {Integer} will store the final caret position
        var range,
            iCaretPos = 0;
        // IE Support
        if (document.selection) {
          // Set focus on the element
          elem.focus();
          // To get cursor position, get empty selection range
          range = document.selection.createRange();
          // Move selection start to 0 position
          range.moveStart('character', -elem.value.length);
          // The caret position is selection length
          iCaretPos = range.text.length;
        } else if (elem.selectionStart || elem.selectionStart === 0) {
          // Firefox support
          iCaretPos = elem.selectionStart;
        }
        // Return results
        return iCaretPos;
      }
docs: Method that returns the current caret (cursor) position of a given element.
  Source: http://stackoverflow.com/questions/2897155/get-cursor-position-in-characters-within-a-text-input-field
  @method getCaretPosition
  @param elem {element} the DOM element to check caret position
  @return {Integer} the cursor index of the given element.