Weird issue (?) with form validation/submit

Weird issue (?) with form validation/submit

Hi,

I have a form on my page, which I want to validate on submit.

The code looks something like this:

$('#form').submit(function(){    
    if ($('#field1').length == 4 && $('#field2').length == 3) {
        $.ajax({
            url: someAjaxUrl,
            dataType: 'html',
            type: 'get',
            success: function(html){    
                if (html != '') {
                    //show error
                }
                else {
                    //submit form
                }    
            }
        });
    }
    else {
        //show other error
    }    
    return false;
});

Now, if I try to use

$('#form').submit();

in the else statement within the success function, the validation keeps getting triggered in an endless loop.

But if I use

document.form.submit();

- or document.getElementById('kbaFormSearch').submit(); -

the form gets submitted correctly.

Is this because the anonymus callback function within the earlier defined $('#form).submit() gets triggered again?
And if so, is there a way to get this to work without using "native JS" (not that I'm against it, but it would not make much sense to me unless there is no other way).

Thanks!