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');
}
})
精彩评论