JS 驗證一組input框是否為空的方法


function checkInput() {
  var $tr = $("#tb_confirmed .scrollContent").find("tr");
  var flag = 0;
  var antiqueTypes = [];
  
  $tr.each( function( index, item ){
      var type = $(item).find("input[type='text']").val();
          
      antiqueTypes.push(type);

  }); 

  $.each(antiqueTypes, function(index, item){
    
       if( item.length == 0 ){
        flag += 1;  
        $("order-tips").find("span").text("請輸入商品物流單號");
     }
  });
  return flag;

}

// 調用此方法, 可以在別的方法中調用它

if( checkInput > 0 ){
  $("order-tips").find("span").text("請輸入商品物流單號");
   return false;

} else {

   ajax() // 請求
}

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM