I am developing a form process with several fields, each accompanied by a secondary hidden field for validation purposes. The workflow automatically populates these hidden fields, and I want to implement a warning system that alerts the user if their input does not match the workflow's output. Currently, I'm using field rules combined with a custom HTML activity to display a warning when both primary fields are filled but do not match (i.e., field1 != field2). However, I'm encountering an issue where the warning is triggered prematurely—before the user finishes inputting their data in field1. How can I adjust the timing of the rule so that the warning only appears after the user has fully entered their data?
I have been using some basic javascript in the classic designer but cannot get it working in the modern designer, any assistance would be greatly appreciated.
$(document).ready(function() { function compareFields() { $('.Submit').show(); $('.warningText').remove(); var field1 = $('.field1 input').val(); var field2 = $('.field2 input').val(); // Check if field 2 has a value if (field2 !== '') { // Compare Field 1 and Field 2 values if (field1 !== field2) { $('<p class="warningText"><font color="red">Field 1 and Field 2 do not match.</font></p>').insertAfter('.field2 input'); } } else { $('<p class="warningText"><font color="red">Field 2 must not be empty.</font></p>').insertAfter('.field2 input'); } } // Trigger the comparison when Field 1 or Field 2 lose focus $('.field1 input, .field2 input').blur(compareFields); });