var tries=0; function workstationdetails() { var output = ""; output += "
| \n";
output += "\n";
output += "1-3 Workstations $1,500.00 \n"; output += "\n"; output += "4-7 Workstations $2,500.00 \n"; output += "\n"; output += "8-11 Workstations $3,500.00 \n"; output += " Optional: If you know the IP addresses of the workstations ";
output += "involved, list them here. | \n\n"; output += ""; output += "No modem or proxy access allowed. " output += "Static IPs are required for each workstation.\n"; output += "\n | \n
\n"; output += "
\n"; output += "
\n"; output += "
\n"; output += "
\n"; output += "
\n"; output += "
\n";
document.getElementById("unlimiteddetails").innerHTML=output;
document.getElementById("workstationdetails").innerHTML='';
/* since that's a fake radio button not with the "subscription" one,
turn the workstation main radio button off manually otherwise both
look checked */
document.getElementById("placeholder").checked=false;
}
function validateForm ( form )
{
var retval = true; // be optimistic!!
var silent = false;
var missingq = false;
var otherq = false;
var errname;
try {
for ( var e=0; e < form.elements.length; e++ )
{
var el = form.elements[e];
if (el.name != '')
{
errname = el.name + "error";
}
if (errname != '')
{
// ban html coding
if (el.type != 'radio' && el.value != '')
{
var ndx = el.value.search(/(<|htm|http)/);
if (ndx >= 0)
{
retval=false;
silent=true;
}
}
if (el.name=='title'||el.name=='state'||
el.name=='zipcode'||el.name=='fax'||
el.name=='department'||el.name=='invoice'||
el.name=='questions'||el.name=='submit'||
el.name=='workstationips'||
el.name=='reset'||el.id=='placeholder')
{
// these are optional fields
// but reject junk in non empty fields
if ((el.name=='fax'||el.name=='workstationips') &&
el.value != '')
{
var ndx = el.value.search(/[^0-9-.\s()+]/);
if (ndx >= 0)
{
retval=false;
silent=true;
}
}
}
else if (el.type == 'radio')
{
var group = form [el.name];
var checked = false;
if (!group.length)
checked = el.checked;
else
for ( var r = 0; r < group.length; r ++ )
if ( ( checked = group [ r ].checked ) )
break;
if ( !checked )
{
var output = "Please choose an option!";
document.getElementById(errname).innerHTML=output;
otherq = true;
retval = false;
}
/* need to make sure unlimited has opened up
questionnaire and answered the questions...it's
possible to wind up with unlimited clicked but not
showing the q., in which case this simple validation
fails since it doesn't examine specific names
otherwise in the radio check */
else if (el.name=="subscription" &&
el.value=="unlimited" &&
el.checked==="true")
{
/* since it's all or nothing display, only need
to check for one of the q's names, if it's
defined, then we need do nothing further as this
will catch missing ones. if it's undefined,
then put out a message about clicking the
unlimited again and answering the q's */
if (document.getElementById("totalfteid") == null)
{
retval = false;
missingq= true;
}
}
else
{
document.getElementById(errname).innerHTML='';
}
}
else if (el.value == '')
{
var output = "";
output += "Please fill in required field!";
document.getElementById(errname).innerHTML=output;
retval = false;
otherq = true;
}
else
{
document.getElementById(errname).innerHTML='';
if (el.name=='email')
{
var ndx1 = el.value.search(/^([\w.-])+@([\w])+\./);
var ndx2 = el.value.search(/\.([a-z])+$/);
if (ndx1 < 0 || ndx2 < 0)
{
retval=false;
silent=true;
}
}
/* can't restrict, really -- "no phone" and
"xxxxx or xxxxx" are okay, so screw that
if (el.name=='phone')
{
var ndx = el.value.search(/[^0-9-.\s()+]/);
if (ndx >= 0)
{
retval=false;
silent=true;
}
}
*/
if (el.name=='firstname' || el.name=='lastname' ||
el.name=='state' || el.name=='country')
{
var ndx = el.value.search(/\d/);
if (ndx > 0)
{
retval=false;
silent=true;
}
}
}
}
}
}
catch (e)
{
/*
alert("An exception occurred in the script. Error name: " +
e.name + ". Error message: " + e.message);
alert("errname is " + errname);
*/
retval = false;
}
document.getElementById('generalerror').innerHTML='';
tries++;
if (tries >= 3)
{
//alert("too many failures");
document.getElementById('generalerror').innerHTML=
"\n";
return true;
}
if (retval===false)
{
if (missingq===true)
{
var output = "";
output = "" +
"Please fill out the questionnaire under Unlimited " +
"Subscription (click on button again to show questions)";
if (otherq===true)
{
output += "
and please also fill out other fields as " +
"indicated above";
}
output += "!";
document.getElementById('generalerror').innerHTML=output;
}
else
{
// if a required field is empty, trump the silent marker,
// it could have both bogus and missing so check both
// indicators.
if (silent===false||otherq===true)
{
document.getElementById('generalerror').innerHTML=
"" +
"Please go back and fill in required field(s)!";
}
}
return false;
}
else
{
return true;
}
}