开发者

Warn if at least one value not empty

开发者 https://www.devze.com 2023-03-08 10:41 出处:网络
I have a set of form fields generated via a loop: foreach ($arrays as $listValue) { echo \' <div> <input type=\"text\" maxlength=\"100\" name=\"field[]\">

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

精彩评论

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