Yes, there is, but it's complex because IE and decent browsers have different ways of going about it. In Firefox, Safari and Opera it would be very simple:
var selectedText = inp.selectionEnd - inp.selectionStart > 0;
where inp is a reference to the text box. The selectedText var would be true or false, indicating if text was selected. IE requires you to use document.selection and follow a roundabout way of finding the length of the selected text.
But from what you describe, it seems like maxlength will do what you want.