Removing empty Input Elements from a form

后端 未结 4 1155
梦如初夏
梦如初夏 2021-01-14 21:20

I have a simple form that goes on to create all the form and validation requirements for codeigniter. What I want to do is filter out any empty inputs prior to serializatio

4条回答
  •  情歌与酒
    2021-01-14 21:55

    This will remove all the text fields which have a value of length 0:

    $('#send').click(function(){ 
    $(':input[type="text"]').filter(function(e){
        if (this.value.length===0){
          return true;
        }  
    }).remove();
        });
    

    example: http://jsfiddle.net/niklasvh/ZBSyX/

提交回复
热议问题