// Validation routines for the TAMHSC Whitepages //// Author: Charlie S. Lindahl// Date  : 8/29/2006//// These javascript routines are called from the main search// page for the TAMHSC whitepaoges system. //// validate_component: make sure the user has selected a compoennt// from the drop-down combo box. //// If a component has NOT been selected, a Javascript alert dialog// is issued projmpting the user to select one.function validate_component() {        var theComponent = document.selectComponentForm.selectComponentforDepartment.value;        //alert('validate_component, component=' + theComponent);        if (theComponent == -1) {                alert('Must select a component');                return false;        }        return true;}//// validate_names://// The user can specify either a first name, a last name, and a// particular component in the query. //// The textual inputs must be alphabetic and/or have a single// quote. Any other value(s) are inavlid (this helps prevent// form-based cross-scripting attacks). //// In addition (for efficiency) the user must enter a minimum// of 2 characters in the search. //function validate_names() {        var theFirstName = document.selectNamesForm.FirstName.value;        var theLastName  = document.selectNamesForm.LastName.value;        var theComponent = document.selectNamesForm.selectComponentforName.value;        //alert('validate_names - FirstName="' + theFirstName + '"' +        //      ', LastName="' + theLastName + '"');        //        // Check for *any* inputs        //        if ((theFirstName.length == 0) && (theLastName.length == 0)) {           alert('Must specify a name to search');           return false;        }        //        // Check first name pattern        //        if (theFirstName.length > 0) {                // Must have at least 2 characters                if (theFirstName.length < 2) {                   alert('Must have at least two characters ' +                        'in the first name');                   return false;                }                // And only letters and a single quote                if (!theFirstName.match(/^([a-z]|[A-Z]|\')+$/)) {                   alert('Must only have letters and/or single quote in first name');                   return false;                }        }        if (theLastName.length > 0) {                // Must have at least 2 characters                if (theLastName.length < 2) {                   alert('Must have at least two characters ' +                        'in the last name');                   return false;                }                // And only letters and a single quote                if (!theLastName.match(/^([a-z]|[A-Z]|\')+$/)) {                   alert('Must have letters and/or single quote in last name');                   return false;                }        }        return true;}// validate_department: make sure the user has selected a department// from the select menu. //// If a department has NOT been selected, a Javascript alert dialog// is issued projmpting the user to select one.function validate_department() {		var theDepartment = document.DepartmentListForm.selectDepartment.value;        //alert('validate_department, department=' + theDepartment);        if (theDepartment == "") {                alert('Must select a department');                return false;        }        return true;}// validate_name: make sure the user has selected a name// from the select menu. //// If a name has NOT been selected, a Javascript alert dialog// is issued projmpting the user to select one.function validate_name() {		var theName = document.NameListForm.selectName.value;        //alert('validate_department, department=' + theDepartment);        if (theName == "") {                alert('Must select a name');                return false;        }        return true;}