Hi team,
I'm trying to bring a little more structure to some of the complex forms we're building, especially as they start growing beyond four or five pages, and exceed 100+ variables.
Those drop down menus behind the scenes (like the field rules pages) become quite a nightmare to navigate when you start piling on the fields and variables with similar names. So we've started prefixing field names with their sections to make it more manageable (e.g. [01], [02] etc).
All of our fields are pre-fixed based on their page in the form.. Since this form has 10 pages, the fields go up to 10. Sometimes there are pages and sections that are conditionally shown depending on whether a field has been selected or is true or not.
So, in an effort to improve the experience for both the designer and the end user I embarked on a little adventure to see if I could use Javascript to search and replace (to remove) the prefix from the front end.
I had some success pretty quickly..
The issue I'm finding now however, is that the associated field rules for these fields no longer work. So I'm curious to know whether or not I need to refine my search and replace somehow.
I was hoping someone may understand what I'm missing as the console displays no errors.
$(document).ready(function(){ $("span").html(function() { return $(this).html().replace("[01]", ''); }); $("span").html(function() { return $(this).html().replace("[01a]", ''); }); $("span").html(function() { return $(this).html().replace("[01b]", ''); }); $("span").html(function() { return $(this).html().replace("[01x]", ''); }); $("span").html(function() { return $(this).html().replace("[02]", ''); }); });
Not shown above, similar code works for the section headers by using the following:
$("h2").html(function() { return $(this).html().replace("[01a.]", ''); });
If anyone has come across something similar and/or is slightly more advanced with Javascript the help would be greatly appreciated.
Cheers!