//this function checks verifies that atleast one form field has valid search term that is 2 or more characters in //length. A one character search is not permitted. //Title: validateSearch_c //Created By: Tim Murnane -- Idea Integration 6/2001 //Requires validatecommonc.js for isEmpty() function function isValidSearch(strText) { if (!isEmpty(strText)) { titleString = (strText); titleString = titleString.replace(' and ', " "); titleString = titleString.replace(' or ', " "); titleString = titleString.replace(' not ', " "); inpRE = /(\s*\w{1,}[^'""\s]\s*)|('\s*\w{1,}[^'""\s]\s*')|(""\s*\w{1,}[^'""\s]\s*"")/; result = inpRE.exec(strText); if (result==null) { return false; } return true; } } function validateSearch() { var msg="" var valid=true if (isEmpty(document.frmAdvSearch.txtProductTitle.value) && isEmpty(document.frmAdvSearch.txtAuthorName.value) && isEmpty(document.frmAdvSearch.txtProductISBN.value) && isEmpty(document.frmAdvSearch.txtProductKeywords.value)){ msg = msg + "\n * Must enter search term in at least one of the following fields: Title, Author, ISBN or Keywords.\n"; valid = false; } //title field if (!isEmpty(document.frmAdvSearch.txtProductTitle.value)){ if (!isValidSearch(document.frmAdvSearch.txtProductTitle.value)){ msg = msg + "\n* Illegal search terms were entered in the Title field.\n" + " Entries must be at least two valid characters.\n"; valid = false; } } //author field if (!isEmpty(document.frmAdvSearch.txtAuthorName.value)){ if (!isValidSearch(document.frmAdvSearch.txtAuthorName.value)){ msg = msg + "\n* Illegal search terms were entered in the Author field.\n" + " Entries must be at least two valid characters.\n"; valid = false; } } //ISBN field if (!isEmpty(document.frmAdvSearch.txtProductISBN.value)){ if (!isValidSearch(document.frmAdvSearch.txtProductISBN.value)){ msg = msg + "\n* Illegal search terms were entered in the ISBN field.\n" + " Entries must be at least two valid characters.\n"; valid = false; } } //Keyword field if (!isEmpty(document.frmAdvSearch.txtProductKeywords.value)){ if (!isValidSearch(document.frmAdvSearch.txtProductKeywords.value)){ msg = msg + "\n* Illegal search terms were entered in the Keyword field.\n" + " Entries must be at least two valid characters.\n"; valid = false; } } //Year From field if (!isEmpty(document.frmAdvSearch.intPublicationYearFrom.value)){ if ((isNaN(document.frmAdvSearch.intPublicationYearFrom.value)) || (document.frmAdvSearch.intPublicationYearFrom.value.length < 4)) { msg=msg + "\n* Publication Year 'From' entry must four be numeric characters.\n"; valid=false; } } if (!isEmpty(document.frmAdvSearch.intPublicationYearThru.value)){ if ((isNaN(document.frmAdvSearch.intPublicationYearThru.value)) || (document.frmAdvSearch.intPublicationYearThru.value.length < 4)) { msg=msg + "\n* Publication Year 'To' entry must four be numeric characters.\n"; valid=false; } } if (msg.length > 0 ) { msg = 'Please address the following errors and try again:\n' + msg + '\n\n'; valid=false; } if (valid == true) { return true; } alert(msg); return false; } function validateLeftNav(){ //var errMsg; var Valid = true; var srchCriteria = document.frmSearch.Criteria1Val.value; if (!isValidSearch(srchCriteria)){ alert("\n* Illegal search terms were entered in the Search For field.\n" + " Entries must be at least two valid characters.\n"); Valid = false; } return Valid; }