createRange function is not working in other browsers except IE
<p>I have a text box. When I write first text , then java script function will fire to check whether it is a number.</p>

<p>For IE , the following code is returning -1 value, But Other browsers it does not alert any value. Please help me</p>

<pre><code>var selected = document.selection.createRange();
var decInSel = selected.text.indexOf('.');
hasNegInSel  = selected.text.indexOf('-') != -1;
alert(decInSel);
</code></pre>
