计算具有特定类别的空输入数 [英] counting number of empty inputs with a certain class
本文介绍了计算具有特定类别的空输入数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经尝试了几个从以前的问题的解决方案,但没有运气。希望有人可以帮助我。
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> </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屋!
查看全文