You are viewing limited content. For full access, please sign in.

Question

Question

submit button will not work

asked on June 4, 2020

I have added some JavaScript to my form that we use on other forms of ours and now the submit button on the form will not work.  I have been playing around with syntax for a while and cannot come up with what I did wrong or missed.

The code we have added essentially allows us to use the same form on multiple steps and hide fields on the steps we do not want them to appear on.  We have used this code on other forms processes and not had these issues.  Here is the specific code we are using:

$(document).ready(function(){
  
  $('#q45').hide();  //hide the custom html for stepname
  
function handle_review_sections() {
    //first hide them all
    $('#q35').hide();
    $('#q40').hide();
    $('#q50').hide();
    
    //now show the one that we need to based upon the step name from the custom HTML
    switch ($('#steptag').html()) {
        
      case "Contract Submission Revision": //needs to be the stepname
        $('#q35').show();
        $('#q40').show();
        $('#q50').show();
        break;
    };

  }
  
  handle_review_sections()  
  
})

 

As I am not strong in JS, can someone help me with what I am missing?

Thank you,

Jason

1 0

Answer

SELECTED ANSWER
replied on June 4, 2020

Off the top of my head, I'd bet that your JavaScript is hiding a required field and the submit button is actually working as expected; i.e., preventing submission when a required field is not filled out.

Situations like that are when field rules are usually a better option than custom code. When a field rule hides a required field, that field is ignored in the client-side validation so the form will still submit.

 

If that is indeed what is happening, instead of all the custom show/hide code, you could just create a hidden field for the "steptag" value.

Use JavaScript to populate that "steptag" field when the form loads.

Then set up field rules to show/hide certain fields or sections depending on the step value.

1 0

Replies

replied on June 4, 2020

Jason,

Thank you, rookie mistake for sure and one I thought I had checked early on, but apparently did not.  I added 1 line of code to make that field required on the step where it is visible and I am set.

Thank you!

Jason

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.