开发者

Warn if at least one value not empty

I have a set of form fields generated via a loop:

foreach ($arrays as $listValue) {
    echo '
    <div>
       <input type="text" maxlength="100" name="field[]">
    </div>';
}
<a href="#" id="myLink">link</a>

I also have a link below, that when clicked calls a开发者_StackOverflow社区 jQuery function.

I'd like to add a check and display a warning (alert is fine) if there's at least one value present in the form fields when I click my link.


if($('input[value!=""]').length > 0) {
    //at least one field is filled out 
}


$(':input').each(function(){
     if($(this).val() != '')
     {
        alert('warning');
     }
})
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜