I have an approval process with a required signature field. When the approval decision is "Reject", I would like the form to submit without requiring their signature. Does anyone know the JavaScript to do this?
Question
Question
Make Signature Field Not Required When Form is Rejected
Answer
Since .clearfix will be a class in every signature field on the form, I would avoid using it.
The input is a child of the clearfix class which is a child of the signature field, so to specify only the specific field be changed, (assuming signatureField is the CSS class on the signature field) use $('.signatureField input') instead of $('.clearfix input')
Replies
This is possible to do using just the approval decision buttons. The trick is to set the Signature field to NOT required on the layout tab and set it as required using javascript. Also you will need to give your signature field a class. My example uses signatureField as the class. Please see the following:
$(document).ready(function() { /* NOTE: on the Layout tab set the signature field to NOT required */ /* This sets the signature field to required using javascript */ $('.signatureField label').append('<span class="cf-required">*</span>'); $('.clearfix 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(){ $('.signatureField span.cf-required').remove(); $('.clearfix input').removeClass('required').removeAttr('required'); }); });
Hope that helps,
I was in need of the same functionality, and ended up here. Other than that accidentally targeting all signature fields rather than a specific one (as pointed out above), the other small issue with this code, I noticed, is that since click() runs before validation, if you had another field that was empty, and clicked Reject, the signature field's requiredness would still be removed by this code. You could then click Approve, and it would allow you to. Other than that, it appears to work as expected - so I just also bound to the click event on the Approve button, and added requiredness back to the field it might have been removed from, in the same way.
Hi Vanessa
I think the way to do this is to use a Radio Button to accept the value of Approved or Rejected.
If the user selects Approved then use a field rule to show the required Signature field.
Only display a Submit button for your Action Button (This could be hidden by javascript if you so choose until the radio button is completed)
In your BPM you can use the radio button in an Exclusive gateway for your routing
@SteveKnowlton
Thank you Shawn and Bert! With a combination of your answers, I was able to get my form to behave exactly how I wanted.