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

Question

Question

Show Hide with JavaScript

asked on April 6, 2023 Show version history

I am trying to show hide the submit based on DOB matching and a field that is populated by a lookup rule to tell what kind of resignation was submitted.

 

      if ((($('.dob input').val() != $('.sigdob input').val()) && $('.restype input'.val() =="Summer"))) {
           $('.doberror').show();
        $('.Submit').hide();
      }
      else {
        $('.doberror').hide();
        $('.Submit').show();
      }

 

However, it isn't working.  I'm not great with JS, is there something else that needs to be added?

0 0

Answer

SELECTED ANSWER
replied on April 6, 2023

You are missing a closing parenthesis in the first line:   $('.restype input').val()

If that change by itself doesn't make it work, I think you'll need to provide the full script you are using instead of just this snippet - so we can see the details of what is triggering this particular bit of code.

One tip - use the "code" button on this editor when posting, to make you code easier to read.

1 0

Replies

replied on April 10, 2023

Your code has some syntax errors. I can work with this script: 

$(document).ready(function () {
  
  function test() {
    if ($('.dob input').val() != $('.sigdob input').val() && $('.restype input').val() =="Summer") {
      $('.doberror').show();
      $('.Submit').hide();
    }
    else {
      $('.doberror').hide();
      $('.Submit').show();
    }
  }
  
  test();
  
  $('input').change(function () {
    test();
  })
  
})

You may be able to refer to this to change your code. 

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

Sign in to reply to this post.