1

I would like the below function to fire ONLY if element id #submit is clicked. I was creating another button (back button) and for some reason after my back button was fired, the below code ran regardless... so I need to wrap the below in another condition (only ig #submit is clicked)

submitHandler: function(form) {
    var complete = function(){
          $('.form-container').find('header').hide();
          $(form).fadeOut(function(){
          $('#thanks').fadeIn();
        });
    };

here is the code for the back button -- it runs onclick as supposed to, BUT afterward the 'submit' function above runs. I need the submit above to ONLY run with the submit click not the back click.

//* back button */

document.getElementById('back').addEventListener('click', function () {
    jQuery('.step1').show();
    jQuery('submit3').hide();
    jQuery('#privacyalert').hide();
    jQuery('.step2').hide();
    jQuery('.step3').hide();
    jQuery('#thanks').hide();
    jQuery('#back').hide();

},  false);
Joel
  • 4,503
  • 1
  • 27
  • 41
Dr Upvote
  • 8,023
  • 24
  • 91
  • 204
  • I'm guessing here, but is `back` a ` – James Thorpe Apr 16 '15 at 15:58

2 Answers2

2

Try setting the back button type to type="button". The default is type="submit" so that is most likely triggering it your submitHandler.

Joel
  • 4,503
  • 1
  • 27
  • 41
1

Here it goes

$('#submit').on('click', function(e) {
var complete = function(){
              $('.form-container').find('header').hide();
              $(form).fadeOut(function(){
              $('#thanks').fadeIn();
            });
});
nirmal
  • 2,143
  • 1
  • 19
  • 29