Hi

I have the following fucntion, which works. I would like to prevent the submission of the form in case that errorMessage.length is greater then 0. I tried with e.preventDefault, nothing, I try return false...nothing. Form is still submitted.



Code:
formLogin.on('submit', function(){
               $.ajax({
                   type: 'POST',
                   url: 'backOffice/loginCheck',
                   data: $(formLogin).serialize(),
                   dataType: 'json',
                   success: function(errorMessage){ 
                       
                       if(errorMessage.length > 0) {  
                           $('#errorMessageTop').fadeIn();
                           
                       } 
                        return false;
                   }
                   
               });
               
    
           });
Any help?

Regards,zoreli