首页 > Web开发 > 详细

JS 验证一组input框是否为空的方法

时间:2016-08-03 22:08:51      阅读:337      评论:0      收藏:0      [点我收藏+]
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() // 请求
}

  

JS 验证一组input框是否为空的方法

原文:http://www.cnblogs.com/zsongs/p/5734478.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!