var requiredFieldMessages = new Array();
var requiredMatchingDefaultOK = new Array();
var formatFields = new Array();
var formatSuccesses = new Array();
var formatMatchAllSuccesses = new Array();
var formatFailures = new Array();
var formatMatchAllFailures = new Array();
var formatMessages = new Array();
function evenOutArrays() {
if (requiredFields.length < requiredFieldMessages.length) { requiredFieldMessages.length = requiredFields.length; }
if (requiredFields.length < requiredMatchingDefaultOK.length) { requiredMatchingDefaultOK.length = requiredFields.length; }
if (requiredFieldMessages.length < requiredFields.length) {
var x = requiredFieldMessages.length;
requiredFieldMessages.length = requiredFields.length;
for (var i = x; i < requiredFields.length; i++) {
requiredFieldMessages[i] = "Field " + requiredFields[i] + " is a required field.";
}
}
if (requiredMatchingDefaultOK.length < requiredFields.length) {
var x = requiredMatchingDefaultOK.length;
requiredMatchingDefaultOK.length = requiredFields.length;
for (var i = x; i < requiredFields.length; i++) {
requiredMatchingDefaultOK[i] = true;
}
}
if (formatFields.length < formatSuccesses.length) { formatSuccesses.length = formatFields.length; }
if (formatFields.length < formatMatchAllSuccesses.length) { formatMatchAllSuccesses.length = formatFields.length; }
if (formatFields.length < formatFailures.length) { formatFailures.length = formatFields.length; }
if (formatFields.length < formatMatchAllFailures.length) { formatMatchAllFailures.length = formatFields.length; }
if (formatFields.length < formatMessages.length) { formatMessages.length = formatFields.length; }
if (formatSuccesses.length < formatFields.length) {
var x = formatSuccesses.length;
formatSuccesses.length = formatFields.length;
for (var i = x; i < requiredFields.length; i++) {
formatSuccesses[i] = ".*";
}
}
if (formatMatchAllSuccesses.length < formatFields.length) {
var x = formatMatchAllSuccesses.length;
formatMatchAllSuccesses.length = formatFields.length;
for (var i = x; i < requiredFields.length; i++) {
formatMatchAllSuccesses[i] = false;
}
}
if (formatFailures.length < formatFields.length) {
var x = formatFailures.length;
formatFailures.length = formatFields.length;
for (var i = x; i < requiredFields.length; i++) {
formatFailures[i] = "^[\b]";
}
}
if (formatMatchAllFailures.length < formatFields.length) {
var x = formatMatchAllFailures.length;
formatMatchAllFailures.length = formatFields.length;
for (var i = x; i < requiredFields.length; i++) {
formatMatchAllFailures[i] = false;
}
}
if (formatMessages.length < formatFields.length) {
var x = formatMessages.length;
formatMessages.length = formatFields.length;
for (var i = x; i < requiredFields.length; i++) {
formatMessages[i] = "Field " + formatFields[i] + " is not formatted correctly.";
}
}
} // Ends the "evenOutArrays" function
function areRequiredFieldsPresent(form) {
for (var i=0; i < requiredFields.length; i++) {
eval("var field = form." + requiredFields[i]);
if (field) {
// NOTE: THE TRIM JAVASCRIPT FUNCTION MUST BE INCLUDED
// NOTE: THE GETFIELDVALUE JAVASCRIPT FUNCTION MUST BE INCLUDED
if (trim(getFieldValue(field)) == "") {
alert(requiredFieldMessages[i]);
field.focus();
return false; // Return as soon as a failure is detected
} // Ends the check to see if the field value is blank
if (field.defaultValue) {
if ( (getFieldValue(field) == field.defaultValue) && ( !requiredMatchingDefaultOK[i]) ) {
alert(requiredFieldMessages[i]);
field.focus();
return false; // Return as soon as a failure is detected
}
} // Ends the check to see if the field has a default value
} // Ends the check to make sure the field exists
} // Move on to the next field
return true;
} // Ends the "areRequiredFieldsPresent" function