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...
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.
i tried the regular checkboxes validtion and it does not produce any result. Please help me
Javascript
function AreAllSiblingsChecked(chkBox)
{
var parentDiv = GetParentByTagName("div", chkBox);
var childCount = parentDiv.childNodes.length;
for(var i=0; i<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;
}