Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Working on a B-tree form. Reply To: Working on a B-tree form.

#183684
__
Participant

So, let’s say the user selects a branch based on their needs and satisfies the validation conditions for that branch… all the other branches are invalid.

A few possibilities come to mind:

  • Validation for one branch can easily depend on another. For example:
branch:{
    one:{
        validation: function(){ 
            /* validate; return true or false */;
        }
    },
    two:{
        validation: function(){ 
            if( ! branch.one.validation() ){
                return false;
            }
            else{
                /* continue validation; return true or false */
            }
        }
    }
}
  • when validating one branch (or, better yet, when going to the “next” branch), we could explicitly unset values on any “unavailable” branches.
  • on submission, perform one last validation which covers the whole form.

How can we selectively submit?

You may not need to. The server can decide how to validate the form based on early values, just like the front-end can. Unneeded inputs will just be ignored. You could also set an “action” value before submission as a hint at which validation approach to use.