Try this
function isTextSelected(input) {
if (typeof input.selectionStart == "number") {
return input.selectionStart == 0 && input.selectionEnd == input.value.length;
} else if (typeof document.selection != "undefined") {
input.focus();
return document.selection.createRange().text == input.value;
}
}
with this
<input type="text" id="test" value="Some text">
<input type="button" onmousedown="alert(isTextSelected(document.getElementById('test')));" value="Selected?">