Forum Moderators: open
function validate(error_message)
{
select_count=0;
alert("validate"+document.myform.TestCase.length);
for(index=0;index<document.myform.TestCase.length;index++)
{
alert("indexvalue"+index);
if (myform.TestCase[index].checked)
{
select_count=select_count+1;
alert("inside"+select_count);
}
}
if (select_count == 0)
{
alert("Please Select the particular TestCase then click" + ' '+ error_message+select_count);
return false;
}
else if (select_count >= 2)
{
alert("Please Select only one TestCase (not more than one)"+ "then click" + ' ' + error_message);
return false;
}
return true;
}
IF I have two testcases displayed in two rows,its working fine.But if i am having only one test case displayed in an row,i am getting an error
validate:undefined
and its showing as
"Please Select the particular TestCase then click" Edit 0);
Its not going inside the for loop ,when i have only one test case in row and showing validate:undefined ,
even if i am having one test case in an row.But if i have more than one testcases,its working fine.
can any one help me in this regard.
Thanks,
srins.
function validate(error_message)
{
var select_count = 0;
var numItems = 1;if( document.myform.TestCase.length )
{
numItems = document.myform.TestCase.length;
}alert("validate"+numItems);
for(index=0;index<numItems;index++)
{
alert("indexvalue"+index);
var checked;
if( numItems > 1 )
{
checked = myform.TestCase[index].checked;
}
else
{
checked = myform.TestCase.checked;
}
if( checked )
{
select_count=select_count+1;
alert("inside"+select_count);
}
}if (select_count == 0)
{
alert("Please Select the particular TestCase then click" + ' '+ error_message+select_count);
return false;
}
else if (select_count >= 2)
{
alert("Please Select only one TestCase (not more than one)"+ "then click" + ' ' + error_message);
return false;
}
return true;
}