// 30 July 2007 - unifying the validator (ext & internal) by putting it in RMSs.cgi
// See RSL07.20 for explanations
var validator='RMSs.cgi';
var xmlhttp;
var crumbswitch = new Array(); // will remember state of the crumbtrail
var colordone="green";
var colornotdone="red";
function rslInitializePage(whichpage)
{
RSLvalidator('page',whichpage,'none','none');
}
function rslValidate(fieldid)
{
RSLvalidator('field',fieldid,'none','none');
}
function rslValidate2(fieldid,otherfieldid)
{
RSLvalidator('twofields',fieldid,otherfieldid,'none');
}
function rslValidateMemnum(fieldid,otherfieldid)
{
RSLvalidator('memnum',fieldid,otherfieldid,'none');
}
function rslValidate3(fieldid,otherfieldid,morefieldid)
{
RSLvalidator('threefields',fieldid,otherfieldid,morefieldid);
}
function RSLvalidator(dowhat,field1,field2,field3)
{
var sendurl;
if (dowhat=="page")
{
pagenumber=field1;
sendurl=validator+"?&verb=initializePage&pagenumber="+pagenumber;
}
else if (dowhat=="field")
{
docwho=document.getElementById(field1);
f1value=docwho.value;
f1name=docwho.name;
valmessage="&verb=validateField&fieldname="+f1name+"&fieldvalue="+f1value;
sendurl=validator+"?"+valmessage;
}
else if (dowhat=="twofields")
{
docwho=document.getElementById(field1);
f1value=docwho.value;
f1name=docwho.name;
docwho=document.getElementById(field2);
f2name=docwho.name;
f2value=docwho.value;
valmessage="&verb=validateField&fieldname="+f1name+"&fieldvalue="+f1value+
"&f2name="+f2name+"&f2value="+f2value;
sendurl=validator+"?"+valmessage;
}
else if (dowhat=="memnum") // a unique case, which must poll the atttype objects.
{
docwho=document.getElementById(field1);
f1value=docwho.value;
f1name=docwho.name;
maxatttype=4;
atttval=0; // until otherwise discovered
for (i=1; i<=maxatttype; i++)
{
ath="atttype"+i;
docwho=document.getElementById(ath);
ischecked=docwho.checked;
if (ischecked)
{ atttval=i;
i=maxatttype+1;
}
}
f2name="atttype";
f2value="AT"+atttval;
valmessage="&verb=validateField&fieldname="+f1name+"&fieldvalue="+f1value+
"&f2name="+f2name+"&f2value="+f2value;
sendurl=validator+"?"+valmessage;
}
else if (dowhat=="threefields")
{
docwho=document.getElementById(field1);
f1value=docwho.value;
f1name=docwho.name;
docwho=document.getElementById(field2);
f2name=docwho.name;
f2value=docwho.value;
docwho=document.getElementById(field3);
f3name=docwho.name;
f3value=docwho.value;
valmessage="&verb=validateField&fieldname="+f1name+"&fieldvalue="+f1value+
"&f2name="+f2name+"&f2value="+f2value+
"&f3name="+f3name+"&f3value="+f3value;
sendurl=validator+"?"+valmessage;
}
else
{
alert ("Unimplemented validation operation:"+dowhat);
}
xmlhttp=null;
// code for Mozilla, etc.
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
// code for IE
else if (window.ActiveXObject)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlhttp!=null)
{
xmlhttp.onreadystatechange=state_Change;
xmlhttp.open("GET",sendurl,true);
xmlhttp.send(null);
}
else
{
alert("Your browser does not support XMLHTTP.")
}
} // END RSLvalidator
function state_Change() // asynchronously passed to the xmlhttp object,
// as a callback, to do its job whenever the
// message wends its way back from the server.
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
{
// if "OK"
if (xmlhttp.status==200)
{
var instring=xmlhttp.responseText;
// DEBUG:
// var sighandle=document.getElementById("specialmsg");
// sighandle.innerHTML=instring;
// lemme SEE what is coming in.
var inlist=new Array();
inlist=instring.split("&");
// Split the contents into an array inform[fieldname]=fieldvalue
var inform=new Array();
var twopiece=new Array();
while (inlist.length>0)
{
var apiece=inlist.shift();
twopiece=apiece.split("=");
inform[twopiece[0]]=twopiece[1];
}
if (inform['dowhat'] =="validateField")
{
fieldname=inform['fieldname'];
var docwho=document.getElementById(fieldname); // what field we talking about
fieldcolor=inform['fieldcolor'];
docwho.style.background=fieldcolor;
// DEBUG: to view any internal data. E. E. fieldcolor.
// var sighandle=document.getElementById("message2");
// sighandle.innerHTML="Debug specialmsg2:"+fieldcolor;
// lemme SEE what is coming in.
if (inform['message'] != null)
{
msgplacename=fieldname+"MSG";
var docmsg=document.getElementById(msgplacename);
docmsg.innerHTML=""+inform['message']+"";
}
if (inform['disable1'] != null)
{
msgplacename=fieldname;
var docmsg=document.getElementById(msgplacename);
docmsg.disabled=inform['disable1'];
}
if (inform['fname2'] != null)
{
fname2=inform['fname2'];
var docwho=document.getElementById(fname2);
docwho.style.background=inform['fcolor2'];
docmsg.innerHTML=""+inform['fmsg2']+"";
}
if (inform['disable2'] != null)
{
msgplacename=fname2;
var docmsg=document.getElementById(msgplacename);
docmsg.disabled=inform['disable2'];
}
if (inform['fname3'] != null)
{
fname3=inform['fname3'];
var docwho=document.getElementById(fname3);
docwho.style.background=inform['fcolor3'];
docmsg.innerHTML=""+inform['fmsg3']+"";
}
if (inform['disable3'] != null)
{
msgplacename=fname3;
var docmsg=document.getElementById(msgplacename);
docmsg.disabled=inform['disable3'];
}
}
if (inform['dowhat'] =="initializePage")
{ // Set those fields to yellow, who don't contain any data yet and are on our init list.
whichpage=0;
while (inform[whichpage] !=null)
{
fieldname=inform[whichpage];
var docwho=document.getElementById(fieldname); // what field we talking about
if (docwho.value==null||docwho.value=="") //
{
docwho.style.background=inform['fieldcolor'];
}
whichpage++;
}
}
} // 200
} // 4
} // End of state_Change()