JavaScript判断数字

  function cTrim(sInputString,iType)
             {
    var sTmpStr = ' '
    var i = -1
    if(iType == 0 || iType == 1)
    {
     while(sTmpStr == ' ')
     {
      ++i
      sTmpStr = sInputString.substr(i,1)
     }
     sInputString = sInputString.substring(i)
    }
    if(iType == 0 || iType == 2)
    {
     sTmpStr = ' '
     i = sInputString.length
     while(sTmpStr == ' ')
     {
      --i
      sTmpStr = sInputString.substr(i,1)
     }
     sInputString = sInputString.substring(0,i+1)
    }
    return sInputString;
             }


if (isNaN(docform.txtFaultFirstEliminateTimes.value)==true || cTrim(docform.txtFaultFirstEliminateTimes.value,0)=="")

{

alert("只能是数字");
 

return ;

}

你可能感兴趣的:(JavaScript)