var a=文本框.value;
a.length //是长度,,
a.substr(a.length,1) //是最后一个字符

解决方案 »

  1.   

    offsetwidth  如何用啊???
      

  2.   

    <input type="text" name="txt" value="baobao">
    <input type="button" onclick="bao()" value="Get">
    <script language="javascript">
    function bao()
    {
        var len = document.all.txt.value.length;
        alert("Length:" + len);
        alert(document.all.txt.value.charAt(len-1))
    }
    </script>
      

  3.   

    <input type="text" name="txt" value="baobao">
    <input type="button" onclick="bao()" value="Get">
    <script language="javascript">
    function bao()
    {
        var len = document.all.txt.value.length;
        alert("Length:" + len);
        alert(document.all.txt.value.charAt(len-1))
        alert("long:" + document.all.txt.offsetWidth)
    }
    </script>