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.

  • This topic is empty.
Viewing 9 posts - 31 through 39 (of 39 total)
  • Author
    Posts
  • #183658
    nixnerd
    Participant

    Gotcha. Ok. How do you feel about keeping the next button from being clicked at all if validation is not met? What I mean is… having it set to disabled by default and then “unlocking” it when the criteria is met.

    #183659
    __
    Participant

    Could. It’d just be “one of those extra touches”; you’d have to check when it was clicked anyway.

    You might be interested in this sitepoint article. Some (I think most but I’m not sure) browsers have a .willValidate property on form inputs. Hooking into that instead of running your own validation would be fatser than JS validation (plus, less coding), assuming support for whatever you’re validating is good enough.

    #183682
    nixnerd
    Participant

    Whoa… will do. I’m going to read that right now. Sounds very intriguing.

    #183683
    nixnerd
    Participant

    Going back to this:

    My biggest concern is that when the user moves beyond the root level… we’re setting root to display:none. Therefore, I have questions about whether or not the submit button is actually going to submit the root with the given branch. Maybe we could cache it somehow?

    My fear is now the opposite. We’ll have validation rules on ALL input fields… visible or not. 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. So, if the submit button is submitting them all… we’re going to get errors and a contact form that doesn’t work. How can we selectively submit?

    #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.

    #183688
    nixnerd
    Participant

    >The server can decide how to validate the form based on early values

    I guess you’re right. And… there’s a back-end dev on this project so, I’ll let him worry about it. And you’re totally right about having conditional validation. I’ll worry about that when I get there.

    #183700
    __
    Participant

    As long as there’s no naming conflicts, and the back-end guys doesn’t do anything foolish, there shouldn’t be any problems.

    #183702
    nixnerd
    Participant

    As long as there’s no naming conflicts, and the back-end guys doesn’t do anything foolish, there shouldn’t be any problems.

    Sweet.

    #183704
    __
    Participant

    As long as there’s no naming conflicts, and the back-end guys doesn’t do anything foolish, there shouldn’t be any problems.

    …says the man who will never have to deal with any of it.
    Just a grain of salt. Enjoy.

Viewing 9 posts - 31 through 39 (of 39 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.