计算某个类的空输入的数量 [英] counting number of empty inputs with a certain class

查看:15
本文介绍了计算某个类的空输入的数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了之前问题中的几个解决方案,但没有成功.希望有人能帮我.

I have tried a couple of solutions from previous questions, but no luck. Hoping someone can help me out.

我有一个表单的一部分,其中的字段是用某个类动态创建的:

I have a section of a form where fields are dynamically created with a certain class:

 <td><input class="user_field" type="text" name="1[user_fname]"/></td>
 <td><input class="user_field" type="text" name="1[user_lname]"/></td>
 <td><input class="user_field phone" type="text" name="1[user_mobile]"/></td>
 <td><input class="user_field" type="text" name="1[user_email]"/></td>
 <td>&nbsp;</td>

关于模糊,我需要检查是否有空并尝试过:

On blur i need to check for empties and have tried:

$('.user_field').blur(function(){

    //check all fields for complete

    alert ($('.user_field[value=""]').length)

});

并得到0"

推荐答案

这会给你所有的空输入:

This will give you all empty inputs:

$('.user_field').filter(function(){
    return !$(this).val();
}).length;

这篇关于计算某个类的空输入的数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆