posted on October 26, 2023 Show version history

A couple years ago, I asked for help making the signature field not required when the form is rejected (see post https://answers.laserfiche.com/questions/171332/Make-Signature-Field-Not-Required-When-Form-is-Rejected#repliestomain).  I have noticed an issue with the JS I have been using.  What occasionally occurs is someone will click reject and then the signature field is no longer required, but the comments box is required.  So the user inputs a comment and then clicks approved because they changed their mind or something.  At this point the signature box is no longer required, because they initially clicked reject, it allows the user to approve a form without a signature.  Is there a way to do an if/else on the approval buttons in Forms?  Here is my current JS:

$(document).ready(function() {
  
  /* This sets the signature field to required using javascript */
  $('.sig .cf-label').append('<span class="cf-required">*</span>');
  $('.sig input').attr('required','True');
  
  /* This removes the required class and asterisk from the signature field
     when the reject button is clicked, allowing the form to submit */
  $('.Reject').on('click',function(){
    $('.sig span.cf-required').remove();
    $('.sig input').removeClass('required').removeAttr('required');
  });
});

Any help with resolving this issue is greatly appreciated.

0 0