How i can make textfield editable at middle of text
<pre><code>//The porpost of this function is prevent user type any thing intext field except 0-9 and .

//For recieve value,event and keycode from text field.    
    function allowOnlyFloatingPointNumbers(textbox,val,key)
        {
        var MaxLen = 11;
        var val2 = val.replace(/,/g,"");
        var letterNumber = /^[0-9.]+$/;
         if((val2.match(letterNumber)))
          {
                textbox.value = val;
          }
        else
          {
                textbox.value = val.substr(0,val.length-1);
                return;
          }

            var valtmp = val;
            if(valtmp.indexOf(".")&lt;0)
            {
                if(valtmp.replace(/,/g,"").length&gt;MaxLen)
                {
                    textbox.value = addCommas(val.substr(0,val.length-1));
                }
                else
                {
                    textbox.value = addCommas(valtmp.replace(/,/g,""));
                }
            }
            else
            {
                val = val.replace(/[^0-9.]/g, "");         // strip non-digit chars
                textbox.value = addCommas(val);            // replace textbox value
                var indx = val.indexOf(".");
                if(indx&gt;-1)
                {
                    var lng = val.substr(indx+1).length;
                    if(lng&gt;2)
                    {
                        textbox.value = addCommas(val.substr(0,val.length-1));
                    }
                }
            }

        }
    function addCommas(nStr)
                {
                        nStr += "";
                        x = nStr.split(".");
                        x1 = x[0];
                        x2 = x.length &gt; 1 ? "." + x[1] : "";
                        var rgx = /(\d+)(\d{3})/;
                        while (rgx.test(x1)) {
                            x1 = x1.replace(rgx, "$1" + "," + "$2");
                        }
                        return x1 + x2;
                }
</code></pre>

<p>Now if i type 987654321 it will be 987,654,321in textbox</p>

<p>but if i need to edit in middle of text like in change 5 to 0
the text will be 987,643,210 zero is insert at end of text
I need it to be 987,604,321 which part of the function that i should change.</p>

<p>I use IE 9.</p>

<p>Here is example <a href="http://jsbin.com/arivug/1" rel="nofollow">http://jsbin.com/arivug/1</a></p>
