<title>Contact Webmaster</title><font style="font-size: 16pt;">Contact the Webmaster</font><p>
<script language="javascript">
// Validate() javascript function
// Generic form validation function. Pass all fieldnames that must be answered on the form.
// radio button: fails if none are selected
// text: fails if field is blank
// select-one: fails if topmost entry is selected
// returns true if form elements are okay, otherwise false
function Validate() {
var strUserMessage;
var bolResult=true; // assume form is okay
var strField;
var objFocusField=null;
var objField;
var bolRadioButtonSelected=false;
var strFieldMessage="";
// ensure all fields passed exist
strUserMessage="Validate(): Error in form.\n\n";
for (var intField=0; intField<arguments.length; intField+=2) {
objField=arguments[intField];
strFieldMessage=arguments[intField+1];
if (!(objField)) {
strUserMessage=strUserMessage+" Form element '"+strFieldMessage+"' does not exist.\n";
bolResult=false;
}
}
if (bolResult==false) {
alert(strUserMessage);
return bolResult;
}
strUserMessage="Please complete the following fields:\n\n";
// prepare radio buttons
for (var intFields=0; intFields<arguments.length; intFields+=2) {
// assign radio button names so they can been "seen" more easily
if (!arguments[intFields].name && arguments[intFields][0].type=="radio") {
arguments[intFields].name=arguments[intFields][0].name;
arguments[intFields].type=arguments[intFields][0].type;
}
}
// iterate through field objects
for (var intFields=0; intFields<arguments.length; intFields+=2) {
objField=arguments[intFields];
strFieldMessage=arguments[intFields+1];
// if it's a radio button, iterate through all the options to see if one is checked
if (objField.type=="radio") {
bolRadioButtonSelected=false;
// see if this radio button is checked
for (var intRadioButtonOptions=0; intRadioButtonOptions<objField.length; intRadioButtonOptions++) {
if (objField[intRadioButtonOptions].checked) {
bolRadioButtonSelected=true;
}
}
// if none of the radio buttons are checked, fail
if (bolRadioButtonSelected==false) {
bolResult=false;
strUserMessage+=" "+strFieldMessage+"\n";
if (objFocusField==null) { objFocusField=objField[0]; }
}
// if the text field is empty, fail
} else if (objField.type=="text" || objField.type=="password" || objField.type=="textarea" || objField.type=="file") {
if (objField.value=="") {
bolResult=false;
strUserMessage+=" "+strFieldMessage+"\n";
if (objFocusField==null) { objFocusField=objField; }
}
// if the checkbox is empty, fail
} else if (objField.type=="checkbox") {
if (objField.checked==false) {
bolResult=false;
strUserMessage+=" "+strFieldMessage+"\n";
if (objFocusField==null) { objFocusField=objField; }
}
// if the top item is selected, fail
} else if (objField.type=="select-one") {
if (objField.selectedIndex<1 && objField.size<=1) {
bolResult=false;
strUserMessage+=" "+strFieldMessage+"\n";
if (objFocusField==null) { objFocusField=objField; }
}
if (objField.size>1 && objField.value=="") {
bolResult=false;
strUserMessage+=" "+strFieldMessage+"\n";
if (objFocusField==null) { objFocusField=objField; }
}
}
}
// if form isn't complete yet, put cursor on 1st blank entry
if (objFocusField!=null) objFocusField.focus();
if (bolResult==false) {
alert(strUserMessage);
}
return bolResult;
}