//beginning of javascript for text/password field validation.
function validation(textval, formname, alertbox) {
with (textval)
{
//alert (textval);
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}
//end of javascript for text/password validation.

//beginning of javascript for radiobuttons validation.
function returnSelection(rad_chb) {
var selection=null;
for(var i=0; i<rad_chb.length; i++)
{
if(rad_chb[i].checked){ selection=rad_chb[i].value; return selection; }
}
//return selection;
}

function validate_rad(r_chbval, formname, alertbox){
//alert(r_chbval);
if (returnSelection(r_chbval) == null)
{ if (alertbox!="") { alert(alertbox); } return false; }
else return true;
}
//end of javascript for radiobutton validation

//beginning of javascript for checkboxes validation
/*
EXPLANATION:
function validate_check accepts parameters:
i - number of element in the checkboxes list;
checkval - first part of name of checkboxes;
formname - name of form;
min_checked - min number of checkboxes that should be checked;
max_chacked - max number of checkboxes that should be checked;
alertbox - alert message if smth. is wrong.
NAMING OF CHECKBOXES:
name of checkboxes is like name+number where first part (name) is common for all the checkboxes in the group and number should start from one
(e.g. chb1, chb2, chb3... (all in one group) or chb1, chb2, chb3, chx1, chx2 (two different groups)).
*/
function validate_check(i, checkval, formname, min_checked, max_checked, alertbox){
var count_checked=0;
for (var j=1; j<=i; j++) {
//alert(j);
box=eval("document."+formname+"."+checkval+j);
if (box.checked==true){ count_checked++; } }
//alert (count_checked);
if ((count_checked>=min_checked)&&(count_checked<=max_checked)) { return true; } else { if (alertbox!="") { alert(alertbox); } return false;}
}
//end of javascript for checkboxes validation.

//beginning of javascript for list validation.
function validate_list(listval, formname, alertbox) {
with (listval)
{
//alert (listval);
if (value==null || value=="0")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}
//end of javascript for list validation.
