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

Question

Question

"Ignore the data when the field/section/page is hidden" is not working - Replace with Javascript

asked on August 22

We upgraded to Ver. 11 this past January. Since the upgrade, I have had issues with "Ignore the data when the field/section/page is hidden" not working. so I'm trying to replace with Javascript. An upgrade to Ver. 12 might help, but that won't happen for another year or so. I need to do this to all required fields that get hidden in a Field Rule. Anyway, there are two fields in my Form I'm working with initially. If I can get this to work, I can do the same for all other applicable fields:

I had originally set up the following Field Rule:

Since upgrading to Ver. 11, it doesn't let me continue to the next Form, so I deleted the Field Rule and am trying to use javascript to do the same thing. I removed "required" from the "candidate" field and added the following javascript:

  $(document).ready(function(){

//set fields to hidden
  $('.candidate').hide();

//Instead of Field Rules, for Request Type
  $("input[id^=Field22-0]").change(function () { // Request Type = New Request
    if ($(this).is(':checked')){
      $('.candidate').show();
      $('.candidate input[type="radio"]').attr('required', true);
      $('.candidate .cf-label').append('<span class="cf-required">*</span>').change();
    }
  });
  $("input[id^=Field22-1]").change(function () { // Request Type = Change Order
    if ($(this).is(':checked')){
      $('.candidate').removeClass('required');
      $('.candidate input[type="radio"]').removeAttr('required');
      $('.candidate').hide();
    }
  });
  $("input[id^=Field22-2]").change(function () { // Request Type = Renewal
    if ($(this).is(':checked')){
      $('.candidate').removeClass('required');
      $('.candidate input[type="radio"]').removeAttr('required');
      $('.candidate').hide();
    }
  });
  $("input[id^=Field22-3]").change(function () { // Request Type = Termination
    if ($(this).is(':checked')){
      $('.candidate').removeClass('required');
      $('.candidate input[type="radio"]').removeAttr('required');
      $('.candidate').hide();
    }
  });

});  //close document.ready

My issue is that if someone toggles from New Request to Change Order, it adds another asterisk. How do I delete the extra asterisks?

I would really like the Field Rule to work properly because writing javascript to do this is way more work. Any suggestions.

0 0

Answer

SELECTED ANSWER
replied on August 22

I don't have an answer for why the field rule isn't working but I can answer why your JS code is adding additional asterisks.  When a user selects 'New Request' your JS is appending a span which includes the asterisk.  When the user selects anything else the span is not removed.  Selecting 'New Request' additional times is adding additional spans.  If you add a line of code to the non-New Request sections to remove the appended span, it should clean up the asterisk increase issue.  The specific line of code is:

$('.candidate .cf-label span.cf-required').remove();
  $(document).ready(function(){

//set fields to hidden
  $('.candidate').hide();

//Instead of Field Rules, for Request Type
  $("input[id^=Field1-0]").change(function () { // Request Type = New Request
    if ($(this).is(':checked')){
      $('.candidate input[type="radio"]').attr('required', true);
      $('.candidate .cf-label span.cf-required').remove();
      $('.candidate .cf-label').append('<span class="cf-required">*</span>').change();
      $('.candidate').show();
    }
  });
  $("input[id^=Field1-1]").change(function () { // Request Type = Change Order
    if ($(this).is(':checked')){
      $('.candidate').removeClass('required');
      $('.candidate input[type="radio"]').removeAttr('required');
      $('.candidate .cf-label span.cf-required').remove();
      $('.candidate').hide();
    }
  });
  $("input[id^=Field1-2]").change(function () { // Request Type = Renewal
    if ($(this).is(':checked')){
      $('.candidate').removeClass('required');
      $('.candidate input[type="radio"]').removeAttr('required');
      $('.candidate .cf-label span.cf-required').remove();
      $('.candidate').hide();
    }
  });
  $("input[id^=Field1-3]").change(function () { // Request Type = Termination
    if ($(this).is(':checked')){
      $('.candidate').removeClass('required');
      $('.candidate input[type="radio"]').removeAttr('required');
      $('.candidate .cf-label span.cf-required').remove();
      $('.candidate').hide();
    }
  });

});  //close document.ready

 

0 0

Replies

replied on August 22

What is the version of Forms you are using? You mentioned version 11, but what is the complete version with build number?

0 0
replied on August 22

Laserfiche Forms Professional Version 11.0.2311.50564

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

Sign in to reply to this post.