jq判断是为数字

  1.           var reg = /^\d+$/;  
  2.          $(document).on("click","#c_all",function(){  
  3.              var result=0;   
  4.              $("input[name='classhour[]']").each(function(){   
  5.                 result+=Number($(this).val());     
  6.              });  
  7.              if(!reg.test(result)){  
  8.             // if(isNaN(result)){  
  9.                  alert("ID列只能输入数字");  
  10.                  return ;  
  11.              }        
  12.              $("#t_classhour").val(result);      
  13.          })   
    1. //统计总课时  
    2.           var reg = /^\d+$/;  
    3.          $(document).on("click","#c_all",function(){  
    4.              var result=0;   
    5.              $("input[name='classhour[]']").each(function(){   
    6.                 result+=Number($(this).val());     
    7.              });  
    8.              if(!reg.test(result)){  
    9.             // if(isNaN(result)){  
    10.                  alert("ID列只能输入数字");  
    11.                  return ;  
    12.              }        
    13.              $("#t_classhour").val(result);      
    14.          })   

猜你喜欢

转载自www.cnblogs.com/aivnfjgj/p/9023949.html