how to allow a form submit only when fields are selected
<p>i have a few select fields that are dynamically created by the end user and the only way to control them is by adding a class of attribute to it so that all the selects that are displayed use this class name. What i want is when the user presses buy now the form is only submitted when all select fields have a value as in selected. if their not selected or one of htem is not selected the form returns false and does accordingly.</p>

<p>problem is in the if statement where i check is this.val is empty and if it is to return false it does not work. when i press submit the page gets processed. what am i doing wrong?</p>

<p>thanks</p>

<p>this is my code.</p>

<pre><code>$(document).ready(function()  {
        $(".btnbuy").click(function() {

            $(".attribute").each(function() {

                if($(this).val() == '') {
                        $(this).css('border','2px solid red');
                        return false;
                }
                else {
                    return true;
                }

            });


        });


});
</code></pre>
