双精度数据的校验就不写了,你看看下面代码..希望对你有帮助<input name="t1" type="text" id="t1">
<input name="t2" type="text" id="t2" onFocus="chk()">function  chk()
{
    t1num = document.all.t1.value
    if (t1num=="")
       alert("null")
    else
    {
       if (chkt1num())//在这里校验双精度数据,如果成立则执行
       {
          document.all.t2.value = t1num*0.8
       }
    }
}

解决方案 »

  1.   

    试试这个
    <script language="JavaScript">
    <!--
    function bzscs(){
    if(!isNaN(t1.value)){
    var i=Math.round(t1.value*3*100)/100j=(i+'').length-(i+'').indexOf('.')
    if((i+'').indexOf('.')==-1){i=i+'.00'}
    else{
    if(j==2){i=i+'0'}
    else{}
    }
    t2.value=i
    }
    }
    //-->
    </script>
    <body bgcolor="#FFFFFF">
    <input type="text" name="t1">
    <input type="text" name="t2" onclick="bzscs()">
    </body>
      

  2.   

    <input name="a" value="1.25">
    <input name="b" value="move to me" onMouseOver="fixedNumber(this);">
    <script>
    <!--
    function fixedNumber(obj) {
    var px = new Number(a.value*0.8); 
    obj.value=px.toFixed(2);
    obj.focus();
    }
    //-->
    </script>
      

  3.   

    toFixed和toPrecision方法似乎只能在js5.5以上版本运行。