//Set of JavaScript functions used throughout the database...... function trim(aStr) { return aStr.replace(/^\s{1,}/, "").replace(/\s{1,}$/, "") } function fullTrim(aStr) { return trim(aStr.replace(/\s{2,}/g, " ")) } function trimVBars(field) { return field.value.replace(/[|]{1,}/g, ""); } function isEmpty(field){ if (trim(field.value)=="" || field.value=="null"){ return true; } } function checkNotEmpty(field,name) { if (isEmpty(field)) { alert(name +' is a required field !'); field.focus(); return false; } return true; } function checkHasSelected(field,name,index) { if (field.selectedIndex==index) { alert(name +' is a required field !'); field.focus(); return false; } return true; } function dateSplicer(dateField,dateFormat){ var results = new Array(); dateStr = dateField.value; var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; var matchArray = dateStr.match(datePat); if (matchArray == null) { return null; } // parse date into variables if (dateFormat.charAt(0)=="d"){ //what format does the server use for dates? results[0] = matchArray[1]; results[1] = matchArray[3]; } else { results[1] = matchArray[1]; results[0] = matchArray[3]; } results[2] = matchArray[4]; return results; } function isDate(dateField, dateFormat) { // Checks for a valid date format. dateBits = dateSplicer(dateField,dateFormat); if (dateBits == null){return false;}; day = dateBits[0]; month = dateBits[1]; year = dateBits[2]; if ((month < 1 || month > 12) || (day < 1 || day > 31)) { // check month range return false; } if ((month==4 || month==6 || month==9 || month==11) && day==31) { return false; } if (month == 2) { // check for february 29th var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); if (day>29 || (day==29 && !isleap)) { return false; } } return true; } function checkDateRange(fieldName, fieldDesc, dateFormat, rngStart, rngEnd){ UBoundOK = false; LBoundOK = false; if (!isDate(fieldName, dateFormat)){alert('not a date'); return false;}; dateBits = dateSplicer(fieldName, dateFormat); var dateNow = new Date(); var theDate = new Date(dateBits[2], Math.abs(dateBits[1])-1, dateBits[0]); if (dateNow.getTime()+(60*60*24*(365*(rngStart/12))*1000) < theDate.getTime()){ LBoundOK = true; } if (theDate.getTime() < dateNow.getTime()+(60*60*24*(365*(rngEnd/12))*1000)){ UBoundOK = true; } if (!LBoundOK || !UBoundOK){ if(!LBoundOK){ alert('This date needs to be greater than ' + rngStart + ' months in the future!'); fieldName.focus(); }else{ alert('This date needs to be less than ' + rngEnd + ' months in the future!'); fieldName.focus(); } return false; }else{ return true; } } function isNumber(field){ if (isNaN(field.value)==false){ return true; } } function deleteFromView(doc) { if (confirm("This will delete the selected document(s) !")) { doc.applets.view.markSelectedDocumentsForDelete(); doc.applets.view.deleteMarkedDocuments(); } } function modOnClick(link, funcStr1, funcStr2) { var occ = link.onclick.toString() var idx1 = occ.indexOf("{") var idx2 = occ.lastIndexOf("}") link.onclick = new Function(funcStr1 + occ.slice(idx1 + 1, idx2) + funcStr2) } function dlATagOnClicks(doc) { for (var i = 0; i < doc.links.length; i++) { if (doc.links[i].onclick != null) { alert("document.links[" + i + "].onclick\n" + doc.links[i].onclick) } } } function dlHiddenVals(form) { for (var i = 0; i < form.elements.length; i++) { if (form.elements[i].type == "hidden") { alert(form.elements[i].name + " = " + form.elements[i].value) } } } //function to do a quicksearch (all) function searchDB(path,query) { path+="?SearchView&Query="+query+"&Start=1&Count=10&SearchOrder=4"; window.location.href = "/"+path; // path+="?SearchView&Query="+query+"&Count=10"; // window.location.href = "/"+path; } function searchInputKeyPress() { keyed=window.event.keyCode; if (keyed==13){ return false; } }