Handling multiple fields in rules

Home Forums Classic DFFS Handling multiple fields in rules

Tagged: ,

Viewing 4 reply threads
  • Author
    Posts
    • #20301

      Hi,

      I got a form with 4 Tabs. Initially only the first tab shall be visible and as soon as all required fields are not empty the others shall be visible.

      I got it to work with one field but not that all fields must be filled. How to combine the rules so the tabs appear when all fields are filled?

      thanks.
      Christoph

    • #20324
      Alexander Bautz
      Keymaster

        Hi,
        This needs two rules and some custom js. First add two rules.

        First rule
        Rule friendly name: showTabs
        trigger: No trigger (must be triggered manually)
        Visible tabs: list of tabs

        Second rule
        Rule friendly name: hideTabs
        trigger: No trigger (must be triggered manually)
        Hidden tabs: list of tabs

        Then add this to the Custom JS:

        function showTabsWhenAllRequiredFieldsAreFilledIn(){
            var arrOfFields = ["Field1","Field2","Field3"], allFilledIn = true;
            jQuery.each(arrOfFields,function(i,fin){
                if(getFieldValue(fin).length === 0){
                    allFilledIn = false;
                }
            });
            if(allFilledIn){
                clearInterval(showTabsInterval);
                spjs.dffs.triggerRule(["showTabs"]);
            }else{
                spjs.dffs.triggerRule(["hideTabs"]);
            }
        }
        var showTabsInterval = setInterval(function(){
            showTabsWhenAllRequiredFieldsAreFilledIn();
        },1000);

        Change “arrOfFields” to match your fields.

        This will check to see if all fields have been filled in every second, and when they are it will show your tabs.

        Let me know how this works out.

        Alexander

      • #22856

        Hi,

        since I updated DFFS with the latest version I got following error, with the above code.

        ERROR – You are trying to trigger the rule “showTabs”, but there is no rule with this id defined.

        but it did work before. There was never a rule connected with this function.

        thanks for any help.

        this has been resolved.

      • #22859

        sorry Alexander,

        this has been resolved. I found the error already.

        thanks.

      • #22867
        Alexander Bautz
        Keymaster

          I’m glad you figured it out.

          Alexander

      Viewing 4 reply threads
      • You must be logged in to reply to this topic.