Jquery 验证不适用于空字段

Jquery 验证不适用于空字段,jquery,Jquery,我有5个类隐藏的输入字段 <section class="hidden"> <label> <input class="required" ng-model="currentData.name" /> </label> </section> <section> <label> <input class="requ

我有5个类
隐藏的输入字段

<section class="hidden">
        <label>
        <input class="required" ng-model="currentData.name" /> 
         </label>     
</section>
<section>
        <label>
        <input  class="required" ng-model="currentData.id"/> 
        </label>   
</section>
<section>
    <label>
    <input class="required" type="text" ng-model='currentData.age'/>  
    </label>  
</section>
<section class="hidden">
    <label>
    <input class="required" ng-model='currentData.gender'/> 
    </label>
</section>
<section>
    <label>
    <input class="required" ng-model='currentData.description'/>
    </label>    
</section>
现在,我不想对父节元素具有
隐藏的
类的字段进行验证。这是我编写的代码

$form.find('section').not(".hidden").closest('input.required').each(function() {
            if ($this.val().trim() == '') {
                alert()
            }       
        })
但我的问题是,验证对字段不起作用,即使它没有
隐藏的
类。

如果我删除
.not()
方法验证正在工作。这里有什么问题?

最近的
是在父节点中选择的,您应该使用
查找
而不是
最近的

$form.find('section').not(".hidden").find('input.required').each(function() {
    if ($this.val().trim() == '') {
       alert()
    }       
    });
检查下面的代码段以供参考

$('.btn')。单击(函数(){
$('section')。非('.hidden')。查找('input.required')。每个(函数(){
如果($(this).val().trim()=''){
警报()
}
})
});

$form.find('section').not(".hidden").find('input.required').each(function() {
    if ($this.val().trim() == '') {
       alert()
    }       
    });