js校验double

校验是否浮点型:

精确小数后一位

   if(questionTimes!="") {
                    var str = questionTimes;
                    var j = 0;
      for(i=0;i               if (str[i]<"0" || str[i]>"9"){
                if (str[i]=="."&&i==0) {
                        alert("请填写好学时!");
                        return null;
                    }else if (str[i]=="."&&i!=0){
                        if (j==0) {
                         j++;
                         continue;
                         }
                         alert("请填写好学时!");
                         return null;
                    }
                    alert("请填写好学时!");
                    return null;
              }
      }
     }

 

 

你可能感兴趣的:(其他,前端)