function num(value)
       {
           var   filer=/^\d+$/;  
          if(!filer.test(value)) 
           {  
            return false;
           }
           else
           {
           return true;
           }
       }
       //检验是否2位小数的数字
    function isTriDecimal(value)
     {  
                        if(value!=null&&value!='')
                        {  
                            var decimalIndex=value.indexOf('.');  
                        
                            if(decimalIndex=='-1')
                            {  
                                if( !num(value))
                                {
                              
                                  return false;
                                }
                                return true;
                            }
                            else
                            {  
                                       var zhengshu=value.substring(0,decimalIndex);
                                          
                                       if( !num(zhengshu))
                                       {
                                        
                                          return false;
                                       }
                                       var decimalPart=value.substring(decimalIndex+1,value.length);
                                     
                                     
                                       if(decimalPart.length>2)
                                        { 
                                           return false;
                                        }                                   
                                        if(!num(decimalPart))
                                        {
                                       
                                        return false;
                                        }
                               
                              }  
                              
                        }
                        return true; 
                       
       }
posted on 2009-08-17 10:12  悲哀ing  阅读(2214)  评论(0编辑  收藏  举报