Q: how to apply validation to all tags with specific classes? I have a form in a loop. All form fields must be filled at least once.
For fields, I added a class. Next, I check if there is a value.
my form (laravel blade)
@foreach($locales as $locale)
<div>
    <label for="{{$locale.'[title]'}}">Title</label>
        <input class="valid" name={{$locale.'[title]'}} 
               type="text"
               id="{{$locale.'[title]'}}">

   <label for="{{$locale.'[text]'}}" class="control-label">Text </label>
       <textarea class="valid"
                 name="{{$locale.'[text]'}}"
                 id="{{$locale.'[text]'}}">
       </textarea>
</div>
@endforeach

jquery
$(document).ready(function () {
            $('form').on('submit', function (event) {
                validForm();
            });

            function validForm() {
                $('.valid').each(function () {
                    if ($(this).val()) {
                       $result = true;
                       return false;
                    } else {
                        $result = false;
                    }
                });
                if (!($result)) {
                    event.preventDefault();
                    alert('error');
                }
            }
        });

In this part of the code if ($(this).val()) {$result = true;return false;}, if, for example, input has a value, then the loop exits and the textarea is not checked.
But if I remove return false, then all fields of all forms will be required to be filled (how many times the loop will draw them).
How can I check if all fields of at least one form have values?
Or how to get out of the loop correctly?
Now the form has 2 fields, but in the future there may be more, that is, the check should be universal.

A: You can add a class to an parent div like this:
@foreach($locales as $locale)
<div class="part-form">
  <label for="{{$locale.'[title]'}}">Title</label>
    <input class="valid" name={{$locale.'[title]'}} 
           type="text"
           id="{{$locale.'[title]'}}">

  <label for="{{$locale.'[text]'}}" class="control-label">Text </label>
   <textarea class="valid"
             name="{{$locale.'[text]'}}"
             id="{{$locale.'[text]'}}">
   </textarea>
</div>
@endforeach

And then check if any part-form is full filled.
Example based on your code:
$(document).ready(function () {
        $('form').on('submit', function (event) {
            validForm();
        });

        function validForm() {
            $(".part-form").each(function() {
              var empty = $(this).find(".valid").filter(function() {
                return $(this).val().trim() == "";
              });
              if (!empty.length) {
                $result = true;
                return false;
              }
            })
            if (!($result)) {
                event.preventDefault();
                alert('error');
            }
        }
    });

