Natanael
Natanael

Reputation: 389

How to show div after Submit is complet instead click button?

I have a contact form with many field forms. The form sends an e-mail, and I'd like to show a div (the div has css atributes display none, visible hidden) after the submit is complet.

When I use onClick, the div appear if I click a button with all empty forms. Any help?

My JavaScript function:

$(document).ready(function () {
    $('.ipva_form_calculation').submit(function(event){
        $('.ipva_result').show();
            return false;
    });
});

My HTML form:

<form action="http://localhost/pedespachante/" method="post"       class="avia_ajax_form av-form-labels-hidden   avia-builder-el-4      el_after_av_heading  avia-builder-el-last  ipva_form_calculation av-centered-form  av-custom-form-color av-light-form" data-avia-form-id="1" data-avia-redirect="" style="display: none;">...</form>

Upvotes: 0

Views: 902

Answers (3)

webdevanuj
webdevanuj

Reputation: 675

here is form

<form action="http://localhost/pedespachante/" method="post" id="form_id">
   <input type="text"  name="contact" />
   <div class="error" style="display:none;">Please Fill Contact</div>
</form>



here is jquery

$('#form_id').submit(function() {
   $(this).find('input[type="text"]').each(function() {
   if ($(this).val() == '') {
    //one or more fields is empty, hence stop here
      return false;
    }
  });
  $('.error').show();
});


Hope its work for you!

Upvotes: 0

divix
divix

Reputation: 1364

Use jQuery submit() handler instead: https://api.jquery.com/submit/

$('#myForm').submit(function(event) {
  //do some form validations
  $(this).find('input[type="text"]').each(function() {
      if ($(this).val() == '') {
          //one or more fields is empty, hence stop here
          return false;
      }
  });

  $('.div').show();
});

Upvotes: 2

webdevanuj
webdevanuj

Reputation: 675

Use submit event of JQuery

$('#ur_form_id').submit(function(e) {
  $('.div_class_name').show();
});

Upvotes: 1

Related Questions