We have a form that is somewhat complicated to complete, and we've added functionality to allow the initiator to route to someone else to review/edit (this is a loop, and they can send to as many people as they want before the process continues).
If routing to someone else to assist with completing the form, we want to ignore all the required fields on the form *EXCEPT* for the field where they enter the name of the user the form should route to.
The only part of this that's throwing us for a loop is setting the focus on that field. It works in Preview, but when actually clicking Submit in a live process, it's putting the focus back on the first required field on the form. We believe this is because of the post-submit validation that's done (when the form looks for required fields).
Here's our code:
$(document).ready (function () { /* Ignores required fields when submitting for review */ $(".action-btn.Submit").on('click', function() { let routingChoice = $('.routingSelection input:checked'); let routingTo = $('.routingTo select'); /* if they did not choose Done! and have actually made a routing choice */ if(routingChoice.val() !== 'Done!'&& routingChoice.length >0 ) { /* if they have chosen someone to route to */ if(routingTo.val().length>0){ $("*[required]").each(function() { $(this).removeClass('required'); $(this).removeAttr('required'); }); } else/* nobody was chosen for route to */ { routingTo.trigger('focus'); }; }; }); }); /* END: $(document).ready (function () */
Any ideas?
If we can't get this to work, our alternative will be to just add an alert telling them which field they need to complete to continue (less ideal).
Thanks in advance!