请教判断N个文本框内容是否为数字(有点小问题,请帮忙改改)
<SCRIPT language="javascript" type="text/javascript">var i=0;
function checvalue()
{
var kf = document.all("CASEKPITEM/SUBTOTAL");
i++;
if(isNaN(parseFloat(kf[i-1].value)))
{
alert("请输入有效的数字");
document.all("CASEKPITEM/SUBTOTAL")[i-1].style.background='red';
document.all("CASEKPITEM/SUBTOTAL")[i-1].focus();
return false;
}
if(i==kf.length-1)
{
if(isNaN(parseFloat(kf[i].value)))
{
alert("请输入有效的数字AAAA");
document.all("CASEKPITEM/SUBTOTAL")[i].style.background='red';
document.all("CASEKPITEM/SUBTOTAL")[i].focus();
return false;
}
}
return true;
}
</script>
<input type="text" name="CASEKPITEM/SUBTOTAL"
style="width:50%" >
<input type="text" name="CASEKPITEM/SUBTOTAL"
style="width:50%" onFocus="return checvalue()">
<input type="text" name="CASEKPITEM/SUBTOTAL"
style="width:50%" onFocus="return checvalue()">
<input type="text" name="CASEKPITEM/SUBTOTAL"
style="width:50%" onFocus="return checvalue()">
<input type="text" name="CASEKPITEM/SUBTOTAL"
style="width:50%" onFocus="return checvalue()">