Submit form when validated.
Hi there!
I have this create user form, and I'm checking if the email hasn't been used already.
This works... But what my problem is, that if the email has not been used before, it will not send the form, while I return true.
I've tried to use $(this).submit, but that will just make it loop and never stop.
So basically:
- if data.is_dublicate = true show error
- else data.is_dublicate = false submit the form
Anyone who can help me out?
- $("#add_user").submit( function(){
- var error = $('#dublicate');
- $.post(domain.com/check_dublicate_email', {email: $("#email").val()}, function(data){
- if(data.is_dublicate){
- $(error).html(data.message);
- $(error).fadeIn();
- }else{
- $(error).fadeOut();
- return true;
- }
- }, 'json');
- return false;
- });