if (isNumeric(b))里的返回值只是if的条件,决定程序块的执行,造成你的问题的应该在if里的语句块里!
isNumeric () javascript了好象没有这个方法!!
function isNumeric(str){ var i=0; var j=0; while(i<=str.length-1){ str1=str.charAt(i); if (str1=='.'){ if ((j>0)||(i==0)||(i==(str.length-1))) return false; j=j+1; } else if(isNaN(parseInt(str1))==true) return false; i=i+1;} return true; } function isinfanwei(str) { var newnum=www.split(".") if(newnum[0].length>3) { alert("The integer part length of the number:"+str+" is more than 3!"); return false; } if(newnum[1].length>2) { alert("The decimal part length of the number:"+str+" is more than 2!"); return false; } return true; } 是我自己写的也在javascript里.
function isinfanwei(str) { var newnum=www.split(".") if(newnum[0].length>3) { alert("The integer part length of the number:"+str+" is more than 3!"); return false; } if(newnum[1].length>2) { alert("The decimal part length of the number:"+str+" is more than 2!"); return false; } return true; } 这段程序有错,不知道错在哪里?
找到了 var newnum=www.split(".") 应该是 var newnum=str.split(".")
var i=0;
var j=0;
while(i<=str.length-1){
str1=str.charAt(i);
if (str1=='.'){
if ((j>0)||(i==0)||(i==(str.length-1)))
return false;
j=j+1;
}
else if(isNaN(parseInt(str1))==true) return false;
i=i+1;}
return true;
}
function isinfanwei(str)
{
var newnum=www.split(".")
if(newnum[0].length>3)
{
alert("The integer part length of the number:"+str+" is more than 3!");
return false;
}
if(newnum[1].length>2)
{
alert("The decimal part length of the number:"+str+" is more than 2!");
return false;
}
return true;
}
是我自己写的也在javascript里.
{
var newnum=www.split(".")
if(newnum[0].length>3)
{
alert("The integer part length of the number:"+str+" is more than 3!");
return false;
}
if(newnum[1].length>2)
{
alert("The decimal part length of the number:"+str+" is more than 2!");
return false;
}
return true;
}
这段程序有错,不知道错在哪里?
应该是 var newnum=str.split(".")