Looping over input elements with jQuery each()
<p>I have  written some code that basically attach handler to onsubmit event, but there is a bug that I don't know how to fix.The problem is that when input fields in the form are empty , and code enters the <code>if</code> block, it doesn't stop after return statement, ajax code below is also executed, but I don't understand why ?</p>

<pre><code>$('document').ready(function() {
  $('form').bind('submit', function(event) {

        event.preventDefault();
        $('form input').each(function() {
            if( !$(this).val()) {
                $(this).addClass('warning');
                return;
            }
        });


        $.ajax({
            url: 'http://example.com/',
            dataType: 'json',
            type: 'GET',

         });
  });
});
</code></pre>
