Validation in javascript for asp.net tree node
<p>I have a program with a tree control to assign user permissions like student can access only attendance and staff can assign attendance to students and so on...</p>

<p>I want to validate this with javascript to see that if no checkbox in tree is selected or all nodes in a tree is deselected or left empty ..i have to throw a validation error using javascript. I have attached by design coding and js coding i have used until now.</p>

<p>i tried the regular checkboxes validtion and it does not produce any result. Please help me</p>

<p>
                  
                  
                  
                  
                  
              </p>

<p><strong>Javascript</strong></p>

<pre><code>function AreAllSiblingsChecked(chkBox)
   {
     var parentDiv = GetParentByTagName("div", chkBox);
     var childCount = parentDiv.childNodes.length;
     for(var i=0; i&lt;childCount; i++)
     {
        if(parentDiv.childNodes[i].nodeType == 1) //check if the child node is an element node
        {
            if(parentDiv.childNodes[i].tagName.toLowerCase() == "table")
            {
               var prevChkBox = parentDiv.childNodes[i].getElementsByTagName("input")[0];
              //if any of sibling nodes are not checked, return false
              if(!prevChkBox.checked) 
              {
                return false;
              } 
            }
        }
     }
     return true;
   }
</code></pre>
