//Global Fields //Array to hold the mandatory error field values gManErrFields = new Array() gManErrLabels = new Array() //Array to hold the other error field values gOtherErrFields = new Array(); gOtherErrLabels = new Array(); //Array to hold the numeric error field values gNumErrFields = new Array() gNumErrLabels = new Array() //Array to hold the date error field values gDateErrFields = new Array() gDateErrLabels = new Array() var gNumErr1 RangeFields= new Array() RangeLabels = new Array() //Global handle to the Mandatory Error Window var gManErrWindow = null //Global handle to the Numeric and Date Error Window var gNumErrWindow = null // Global error messages gMandatoryMsg = "The following field(s) are required to be filled :"; gNumericMsg = "The following field(s) require numeric value :"; gDateMsg = "The following field(s) contain invalid date :"; // Global array for allowed date delimiters var gDelim = new Array(":","/","\\","-"," ","."); var gDocSave = true; var gSaveClicked = false; var gFieldName= null; function replaceString(pStr, pReplaceStr, pSep, pPos) { var tempArray = pStr.split(pSep) tempArray[pPos-1] = pReplaceStr return tempArray.join(pSep) } /*Generic Functions for Grid*/ /* ---------------------------------------------------------------------- Function:addToList Purpose:This is a generic function, which adds the values to the grid. It is called when user clicks on the add button Input Parameters:pListObj-List to which the values to be added pfieldObjArray-Array of handles to fields whose values are to be added to the grid pSizeArray-Array of sizes of the fields. This is required to pad the field values with spaces to get fixed length so that the field values of all the elements are formatted equally in the grid pSep-The separator between the field values Return Value:None ------------------------------------------------------------------------- */ function addToList( pListObj, pFieldObjArray, pSizeArray, pSep ) { numFields = pFieldObjArray.length; joinArray = new Array(); var i = 0; var value =0; for( i = 0; i < numFields; i++) { //Get the value from the field depending upon the type of the field // and simultaneously empty them of all values ( In case of type == Text ) value = ""; if( pFieldObjArray[i].type == "text" | pFieldObjArray[i].type == "hidden") { value = pFieldObjArray[i].value; //Don't empty if the field is hidden(computed) if( pFieldObjArray[i].type != "hidden") pFieldObjArray[i].value = ""; } else { if( pFieldObjArray[i].type == "select-one") { value = pFieldObjArray[i].options[pFieldObjArray[i].selectedIndex].text; } else { if( (pFieldObjArray[i])[0].type == "checkbox"); { var tempObj = pFieldObjArray[i]; var numOptions =0; var ci =0; var cj =0; var tempArray; numOptions = tempObj.length; tempArray = new Array(numOptions); for( ci =0; ci < numOptions; ci++) { if(tempObj[ci].checked == true) { tempArray[cj] = tempObj[ci].value; tempObj[ci].checked = false; cj = cj + 1; } } if( cj >= 1) { if( cj == 1) { value = tempArray[0]; } else { value = tempArray.join("+"); } } } } } value = padValue(value, pSizeArray[i]); joinArray[i] = value; } str =joinArray.join(pSep); pListObj.options[pListObj.length] = new Option(joinArray.join(pSep)); } /* ---------------------------------------------------------------------- Function:removeFromList Purpose:This is a generic function, which removes the selected element from the list and puts the values in to the fields for editing/deleting the values Input Parameters:pListObj- List from which the selected entry is to be edited/deleted pfieldObjArray-Array of handles to fields pSep-The separator between the field values Return Value:None ------------------------------------------------------------------------- */ function removeFromList( pListObj, pFieldObjArray,pSep) { count =pListObj.selectedIndex; if( count == 0 |count == 1 | count == -1 ) { alert("Select a valid entry in the grid !") return false; } selectString=pListObj.options[count].text ; splitArray = new Array(); splitArray = selectString.split(pSep); numFields = splitArray.length; for( i = 0; i < numFields; i++) { //Set the value from the field depending upon the type of the field value =rTrim(splitArray[i]); if( value != "") { if( pFieldObjArray[i].type == "text" | pFieldObjArray[i].type == "hidden") { //Don't set the field value if the field is hidden(computed) if( pFieldObjArray[i].type != "hidden") pFieldObjArray[i].value = value; } else { if( pFieldObjArray[i].type == "select-one") { for( j = 0; j < pFieldObjArray[i].length; j++) { if(pFieldObjArray[i].options[j].text == value) pFieldObjArray[i].options[j].selected = true; } } else { if( (pFieldObjArray[i])[0].type == "checkbox") { var tempObj = pFieldObjArray[i]; var numOptions =0; var ci =0; var cj =0; var tempArray; var values = value.split("+"); numOptions = tempObj.length; tempArray = new Array(numOptions); for( ci =0; ci < numOptions; ci++) { for( cj =0; cj < values.length ; cj++) { if(tempObj[ci].value == values[cj]) { tempObj[ci].checked = true; } } } } } } } } // Remove the elements from the list pListObj.options[count] = null; } function replaceListItem( pListObj, pFieldObjArray, pSizeArray, pSep, pKey ) { var i = 0; var itemNumber = -1; var value =0; //Find the position of the key item for(i=0; i < pListObj.options.length; i++) { if(pListObj.options[i].value == pKey) itemNumber = i; } numFields = pFieldObjArray.length; joinArray = new Array(); for( i = 0; i < numFields; i++) { //Get the value from the field depending upon the type of the field // and simultaneously empty them of all values ( In case of type == Text ) value = ""; if( pFieldObjArray[i].type == "text" | pFieldObjArray[i].type == "hidden") { value = pFieldObjArray[i].value; //Don't empty if the field is hidden(computed) if( pFieldObjArray[i].type != "hidden") pFieldObjArray[i].value = ""; } else { if( pFieldObjArray[i].type == "select-one") { value = pFieldObjArray[i].options[pFieldObjArray[i].selectedIndex].text; } else { if( (pFieldObjArray[i])[0].type == "checkbox"); { var tempObj = pFieldObjArray[i]; var numOptions =0; var ci =0; var cj =0; var tempArray; numOptions = tempObj.length; tempArray = new Array(numOptions); for( ci =0; ci < numOptions; ci++) { if(tempObj[ci].checked == true) { tempArray[cj] = tempObj[ci].value; tempObj[ci].checked = false; cj = cj + 1; } } if( cj >= 1) { if( cj == 1) { value = tempArray[0]; } else { value = tempArray.join("+"); } } } } } value = padValue(value, pSizeArray[i]); joinArray[i] = value; } pListObj.options[itemNumber] = new Option(joinArray.join(pSep)); pListObj.options[itemNumber].value = pKey; } /* ---------------------------------------------------------------------- Function:saveList Purpose:This is a generic function, which saves the list elements in to the hidden columns fields using a separator to separate the values for each element Input Parameters:pListObj- Handle to the list pfieldObjArray-Array of handles to the hidden column fields where the list values are going to be stored pSep-The separator between the field values Return Value:None ------------------------------------------------------------------------- */ function saveList( pListObj, pFieldObjArray,pSep) { listSize = pListObj.length; numFields = pFieldObjArray.length; splitArray = new Array(); joinArray = new Array(); for ( i =0; i < numFields;i++) { rowCount = 0; for ( j =0; j< listSize - 2;j++) { splitArray = (pListObj.options[j+2].text).split(pSep); joinArray[j] = splitArray[i]; } pFieldObjArray[i].value = joinArray.join(pSep); } } function saveListValue( pListObj, pFieldObj,pSep) { listSize = pListObj.length; joinArray = new Array(); for ( j =0; j< listSize - 2;j++) { joinArray[j] = (pListObj.options[j+2].value) } pFieldObj.value = joinArray.join(pSep); } function initializeList( pListObj, pFieldObjArray,pSep,pSizeArray) { tempArray = new Array() tempArray = (pFieldObjArray[0].value).split(pSep) numElements = tempArray.length numFields = pFieldObjArray.length splitArray = new Array() joinArray = new Array() for (i =0; i < numElements;i++) { var rowCount = 0 var hasValue = false; for ( j =0; j< numFields;j++) { splitArray = (pFieldObjArray[j].value).split(pSep) if( splitArray[i] != "") hasValue = true; //The following lines of code has been added by Aamir on 03/09/2001 if(typeof pSizeArray != "undefined") { if(splitArray[i] == "" || typeof splitArray[i] == "undefined") splitArray[i] = padValue(" ", pSizeArray[j]); else splitArray[i] = padValue(splitArray[i], pSizeArray[j]); } //Till here joinArray[j] = splitArray[i] } if(hasValue) pListObj.options[i+2] = new Option(joinArray.join(pSep)); } } function initializeListValue( pListObj, pFieldObj, pSep) { //Dont proceed if the field is empty if(pFieldObj.value == "")return false; splitArray = new Array() splitArray = (pFieldObj.value).split(pSep) numElements = splitArray.length for (i =0; i < numElements;i++) { pListObj.options[i+2].value = splitArray[i] ; } return true; } /* ---------------------------------------------------------------------- Function:resetGrid Purpose:This function removes all the entries from the grid Input Parameters:pListObj- Handle to the list Return Value:None ------------------------------------------------------------------------- */ function resetGrid( pListObj) { if( confirm( "This will remove all the entries from the grid. \n Do you wish to continue ?") == true ) { tempText1 = pListObj.options[0].text; tempText2 = pListObj.options[1].text; pListObj.options.length = 2; pListObj.options[0].text = tempText1; pListObj.options[1].text = tempText2; } } /*------------------------------------------------------------------------- Function:padValue Purpose:This function pads each individual element of the row so that values are displayed in a user-friendly manner Input Parameters:pVal - value to be padded pLen- actual length of padded value. Return Value:The Padded element. ------------------------------------------------------------------------- */ function padValue( pVal, pLen) { var i =0; var extraSpaces = 0; if( pVal == "") { pVal ="*" extraSpaces = pLen-1; } else { var strLength = pVal.length; extraSpaces = pLen - strLength } if(extraSpaces >= 0) { for( i = 0; i < extraSpaces; i++) { pVal = pVal + " "; } } else { var trimmedStr = pVal.substr(0,(strLength + extraSpaces -3)); pVal = trimmedStr + "..." } return pVal; } /* ---------------------------------------------------------------------- function openHelp(pKey) Purpose : This function displays help information about the element passed as parameter in another window. Input Parameters: pKey Return Value : None ------------------------------------------------------------------------- */ function openHelp(pKey) { window.open(gFileName + 'HelpForm?openform&key=' +pKey,'new_window','top =0,left =0,toolbar=no,location=no,scrollbars=yes,directories=no,height=170,width=300'); } /* ---------------------------------------------------------------------- Function : popupDate Purpose : This function is used to pop up a browser window and display a date picker applet on it. The chosen date is later reflected in the given datefield Input Parameter : Name of the date field Return value : none ----------------------------------------------------------------------*/ function popupDate(pDateFieldName) { //var file = "/" + document.forms[0].LookupDBPath.value + "/JSCode/CalHTML/$File/Calendar.html "; var file = gFileName + "CalPage?OpenPage" setDateField(document.forms[0][pDateFieldName]); top.newWin = window.open(file,'Date_Window','top =0,left =0,dependent=yes,width=180,height=240,titlebar=yes') top.newWin.focus(); } /* ---------------------------------------------------------------------- function:lTrim( pStr) Purpose:This function trims the extra spaces to the left of the element Input Parameters:pStr - the string to be trimmed Return Value:The trimmed string ------------------------------------------------------------------------- */ function lTrim( pStr) { var resultStr = ""; var i = len = 0; // Return immediately if an invalid value was passed in if (pStr+"" == "undefined" || pStr == null) return null; // Make sure the argument is a string pStr += ""; var resultStr; if (pStr.length == 0) resultStr = ""; else { // Loop through string starting at the beginning as long as there // are spaces. len = pStr.length; while ((i <= len) && (pStr.charAt(i) == " ")) i++; // When the loop is done, we're sitting at the first non-space char, // so return that char plus the remaining chars of the string. resultStr = pStr.substring(i, len); } return resultStr; } /* ---------------------------------------------------------------------- function:rTrim( pStr) Purpose:This function trims the extra spaces to the right of the element Input Parameters:pStr - the string to be trimmed Return Value:The trimmed string ------------------------------------------------------------------------- */ function rTrim( pStr) { var resultStr = ""; var i = 0; // Return immediately if an invalid value was passed in if (pStr+"" == "undefined" || pStr == null) { return null; } // Make sure the argument is a string pStr += ""; if (pStr.length == 0) { var resultStr = ""; } else { // Loop through string starting at the end as long as there // are spaces. i = pStr.length - 1; while ((i >= 0) && (pStr.charAt(i) == " ")) i--; // When the loop is done, we're sitting at the last non-space char, // so return that char plus all previous chars of the string. resultStr = pStr.substring(0, i + 1); } return resultStr; } /* ---------------------------------------------------------------------- function:trim( pStr) Purpose:This function trims the extra spaces to the left and right of the element Input Parameters:pStr - the string to be trimmed Return Value:The trimmed string ------------------------------------------------------------------------- */ function trim( pStr) { return rTrim(lTrim(pStr)); } /* ---------------------------------------------------------------------- function openPBCDialog() Purpose:This function is used to present the PBC selection to the user. The user can do multi-select. Input Parameters:Name of thw field where the selected items will be displayed Return Value:None ------------------------------------------------------------------------- */ function openPBCDialog() { var abURL = gFileName + 'PBCDialog?OpenFrameSet'; var attachWindow = window.open(abURL,'PBC_Window','top =0,left =0,toolbar=no,location=no,scrollbars=yes,directories=no,height=300,width=650') attachWindow.focus(); } /* ---------------------------------------------------------------------- function Unique() Purpose:This function simulates the @Unique formula of Notes formula lang. Input Parameters:Array of String Return Value:Array of String ------------------------------------------------------------------------- */ function unique( pStrArray) { var freshArray = new Array() var counter = 0 for(var i=0; i0 ) { //alert(((pFieldObjArray[i])[0]).name) gManErrFields[iCounter] = ((pFieldObjArray[i])[0]).name } else { gManErrFields[iCounter] = pFieldObjArray[i].name } gManErrLabels[iCounter] = pLabelArray[i] iCounter++; errorCaught = true; } } } return !(errorCaught); } function isBlank( pTextFieldObj ) { // trim the field value var valString ; valString = lTrim(pTextFieldObj.value); if (valString == "" || valString == "") return true; else return false } function isSelected( pFieldObj ) { //alert (pFieldObj.type) //alert(pFieldObj.name); var numCheckboxes ; var i =0; if ((typeof pFieldObj.length) != "undefined") { if( pFieldObj.type == "select-one" | pFieldObj.type == "select-multiple") //if( pFieldObj.type == "--Select--" | pFieldObj.type == "") { var k; //alert(pFieldObj.name); for( k = 0; k < pFieldObj.length;k++) { if(pFieldObj.options[k].selected) { //alert((pFieldObj.options[k].text).charAt(0)); if( (pFieldObj.options[k].text).charAt(0) == "-" || (pFieldObj.options[k].text).charAt(0) == "") { pFieldObj.options[k].selected = false } } } if(pFieldObj.selectedIndex >0 &&pFieldObj.options[pFieldObj.selectedIndex].text != "--Select--") //if(pFieldObj.selectedIndex >= 0 || pFieldObj.options[pFieldObj.selectedIndex].text != "--Select--") { //alert(pFieldObj.name + " || " + pFieldObj.options[pFieldObj.selectedIndex].text); return true; } } else { if ( pFieldObj[0].type == "checkbox" || pFieldObj[0].type == "radio") { numOptions = pFieldObj.length for( i =0; i < numOptions; i++) { if(pFieldObj[i].checked) { return true; } } } } } else { //Checking for single entry checkbox and radio buttons if(pFieldObj.checked) { return true; } } return false; } function checkOthers() { var errorCaught = false; // verify if the value of % completion os between 0 and 100 var towerValue = document.forms[0].tower.options[document.forms[0].tower.options.selectedIndex].text var buValue = document.forms[0].unit.options[document.forms[0].unit.options.selectedIndex].text if( towerValue == "AD/M" && buValue == "Lucent") { lastCount = gOtherErrFields.length gOtherErrFields[lastCount] = "unit" gOtherErrLabels[lastCount] ="Invalid BU for AD/M tower" errorCaught = true; } return !(errorCaught) ; } function checkNumeric(pFieldObjArray, pLabelArray) { var i =0; var numFields ; var iCounter = 0; var errorCaught = false; //Initialize the Numeric Error Array gNumErrFields = new Array() gNumErrLabels = new Array() numFields = pFieldObjArray.length; for( i =0; i < numFields; i++) { //The variable below evaluates to the actual field object and its type var fieldObject = pFieldObjArray[i]; var fieldType = pFieldObjArray[i] .type; if( fieldType == "text" | fieldType == "textarea") { if(!( isNumber(fieldObject.value))) { gNumErrFields[iCounter] = fieldObject.name gNumErrLabels[iCounter] = pLabelArray[i] iCounter++; errorCaught = true; } } } return !(errorCaught) ; } function isNumber( pVal) { oneDecimal = false; inputStr = pVal.toString(); strLength = inputStr.length var commaCounter = 0 ; for( var i = strLength - 1; i >= 0; i--) { var oneChar = inputStr.charAt(i); commaCounter++; //alert( oneChar + " -- " + commaCounter) if( i==0 && oneChar == "-") { continue; } if( oneChar == "." && ! oneDecimal) { oneDecimal = true; commaCounter = 0; continue; } if( oneChar == "," && commaCounter == 4) { commaCounter = 0; continue; } if( oneChar < "0" || oneChar > "9") { return false; } } return true; } function checkDates(pFieldObjArray, pLabelArray) { var i =0; var numFields ; numFields = pFieldObjArray.length; // Flag to see which field should receive focus var iCounter = 0; var errorCaught = false; //Initialize the Numeric Error Array gDateErrFields = new Array() gDateErrLabels = new Array() for( i =0; i < numFields; i++) { //The variable below evaluates to the actual field object and its type var fieldObject = pFieldObjArray[i]; var fieldType = pFieldObjArray[i] .type; // First condition checks for field value of type "text" and "textarea" and "hidden", the else part checks for all other input types if( fieldType == "text" || fieldType == "textarea" || fieldType == "hidden") { if (isBlank(fieldObject)) { continue; } if(!( isDateddmmyy(fieldObject))) { // Add the value to the concatenated message. gDateErrFields[iCounter] = fieldObject.name gDateErrLabels[iCounter] = pLabelArray[i] iCounter++; errorCaught = true; } } } return !(errorCaught) ; } function checkforblank(pFieldObjArray, pLabelArray) { var f=document.forms[0]; var obj; var obj1,a ,b; var DoSubmit=true for(i=1; i<=5 & DoSubmit==true ;i++) { obj= eval('document.forms[0]. Fromdate_'+ i); obj1=eval('document.forms[0].Todate_'+i); //alert(obj1.value); //alert(DoSubmit); if(obj.value==''& obj1.value!='') { alert("Please enter a date in Row:"+ i + " and Column:1");; ///alert("pls enter value"); obj.focus(); return false; } else { if(obj.value!=''& obj1.value=='') { alert("Please enter a date in Row:"+ i + " and Column:2");; obj1.focus(); return false; } else { if(obj.value!='' & obj1.value!='') { return true; } } } } } /* ---------------------------------------------------------------------- Purpose : function isDate(pfieldObject) This function performs date field validation. Input Parameters: pFieldObject : the Date field Return Value : True or False ------------------------------------------------------------------------- */ function isDate(pFieldObject) { //init var month; var day; var year; var monthArray = new Array(0,31,29,31,30,31,30,31,31,30,31,30,31); dtString = ""; dtString = pFieldObject.value; // trim date string while ((dtString.charAt(0) == " ") && (dtString.length != 0)) dtString = dtString.substring(1,dtString.length - 1) while ((dtString.charAt(dtString.length - 1) == " ") && (dtString.length != 0)) dtString = dtString.substring(0,dtString.length - 1) alert (dtString) //get date components i = 0; startPos = 0; pos = 0; //get month do { pos = dtString.indexOf(gDelim[i], startPos); i++ } while ((pos == -1) && (i < gDelim.length)); if (pos == -1) return false; month = parseInt(dtString.substring(startPos,pos),10); alert(month) if(month.toString() == "NaN") return false; startPos = pos + 1; if ((month < 1) || (month > 12)) return false; //get day i = 0; do { pos = dtString.indexOf(gDelim[i], startPos); i++ } while ((pos == -1) && (i < gDelim.length)); if (pos == -1)return false; day = parseInt(dtString.substring(startPos,pos),10); if(day.toString() == "NaN") return false; startPos = pos + 1; if ((day < 1) || (day > monthArray[month])) return false; //get year year = parseInt(dtString.substring(startPos,dtString.length),10); if(year.toString() == "NaN") return false; //check for leap year if ((month == 2) && (day == 29)) { if ((((year % 400) == 0) || (((year % 4) == 0) && ((year % 100) != 0))) == false) { return false; } } //if we've gotten this far, return true return true; } function addHTMLHeader(pWindow) { pWindow.document.writeln("") pWindow.document.writeln("Error Prompt ") pWindow.document.writeln("") pWindow.document.writeln("") pWindow.document.writeln(" ") pWindow.document.writeln("") pWindow.document.writeln("") pWindow.document.writeln("
") } function addHTMLTerminator(pWindow) { pWindow.document.writeln("
") pWindow.document.writeln("") pWindow.document.writeln("") } function showErrors() { var i =0; numArrayLength = gNumErrFields.length if( numArrayLength > 0) { gManErrWindow.document.writeln("" + gNumericMsg + "
") for( i =0; i < numArrayLength ; i++) { gManErrWindow.document.writeln("" + gNumErrLabels[i] + "
") } gManErrWindow.document.writeln("
") } dateArrayLength = gDateErrFields.length if( dateArrayLength > 0) { gManErrWindow.document.writeln("" + gDateMsg + "
") for( i =0; i < dateArrayLength ; i++) { gManErrWindow.document.writeln("" + gDateErrLabels[i] + "
") } gManErrWindow.document.writeln("
") } manArrayLength = gManErrFields.length if( manArrayLength > 0) { gManErrWindow.document.writeln("" + gMandatoryMsg + "
") for( i =0; i < manArrayLength ; i++) { gManErrWindow.document.writeln("" + gManErrLabels[i] + "
") } } othersArrayLength = gOtherErrFields.length if( othersArrayLength > 0) { gManErrWindow.document.writeln("
") for( i =0; i < othersArrayLength ; i++) { gManErrWindow.document.writeln("" + gOtherErrLabels[i] + "
") } } } function setFieldFocus( pFieldName) { if(!(typeof document.forms[0][pFieldName].type == "undefined" && document.forms[0][pFieldName].length >0 ) ) { // In case the requested field is rich text , the pFieldName will have a appended "hd" prefix // In case the requested field is a hidden grid column , the pFieldName will have a appended "col" prefix // We need to remove it before setting the focus if(document.forms[0][pFieldName].type == "hidden") { var tempFieldName; //check if a rich text field tempFieldName = pFieldName.substring(2, pFieldName.length) if(fieldPresent(tempFieldName)) { pFieldName = tempFieldName } } document.forms[0][pFieldName].focus() if(document.forms[0][pFieldName].type == "text") document.forms[0][pFieldName].select(); } else { document.forms[0][pFieldName][0].focus() } } function moveToTab(pNumber) { if(pNumber ==0) stepValue = "Summary" else stepValue ="Step" + pNumber; if( gIsEditMode == "1") { gDocSave=false; document.forms[0].$SSMSteps.value= stepValue _doClick('$Refresh', this, '_self', '#_Refresh_Tabs') gDocSave=true; } else { window.location.href = window.location.pathname + "?OpenDocument&Row=" + stepValue + "#_Refresh_Tabs" } } function replaceString(pStr,pOldStr,pNewStr) { var exp = new RegExp(pOldStr,"gi"); return pStr.replace(exp,pNewStr); } function saveForm() { gSaveClicked = true; var form = document.forms[0]; if (form.onsubmit) { var retVal = form.onsubmit(); if (typeof retVal == "boolean" && retVal == false) { gSaveClicked = false; return false; } } // call the submit of the form form.submit(); } function openTeamDialog(pFieldName) { gFieldName = pFieldName; var abURL = gFileName + 'TeamDialog?OpenFrameSet'; var attachWindow = window.open(abURL,'Team_Window','top =0,left =0,toolbar=no,location=no,scrollbars=yes,directories=no,height=300,width=350') } function removeCommas(pStr) { var numLength = pStr.length var i; var copyStr = ""; var val; for( i= 0; i < numLength; i++) { val = pStr.substring(i, i+1) if (val != ",") { copyStr = copyStr + val; } } return copyStr; } function replaceCommas( pVal) { oneDecimal = false; inputStr = pVal.toString(); //check if the value contains decimal point var strLength = inputStr.length var re = /\./; var searchIndex = inputStr.search(re) if(searchIndex == -1) { startIndex = strLength var replaceStr = "" } else { startIndex = searchIndex var replaceStr = inputStr.substring(searchIndex) } var commaCounter = 0 ; var endIndex = 0; if(inputStr.charAt(0)== "-") { endIndex = 1 } for( var i = startIndex - 1; i >= endIndex; i--) { var oneChar = inputStr.charAt(i); commaCounter++; if( commaCounter == 4) { replaceStr = oneChar + "," + replaceStr commaCounter = 1; } else { replaceStr = oneChar + replaceStr } } if(endIndex == 1) replaceStr = "-" + replaceStr return replaceStr; } ///******************************************************** ///************************************************************************************************************************************************* /* ---------------------------------------------------------------------- Purpose : function isDateddmmyy(pfieldObject) This function performs date field validation. Input Parameters: pFieldObject : the Date field Return Value : True or False ------------------------------------------------------------------------- */ function isDateddmmyy(pFieldObject) { //init var month; var day; var year; var monthArray = new Array(0,31,29,31,30,31,30,31,31,30,31,30,31); dtString = ""; dtString = pFieldObject.value; // trim date string while ((dtString.charAt(0) == " ") && (dtString.length != 0)) dtString = dtString.substring(1,dtString.length - 1) while ((dtString.charAt(dtString.length - 1) == " ") && (dtString.length != 0)) dtString = dtString.substring(0,dtString.length - 1) //get date components i = 0; startPos = 0; pos = 0; //get day do { pos = dtString.indexOf(gDelim[i], startPos); i++ } while ((pos == -1) && (i < gDelim.length)); if (pos == -1) return false; day = parseInt(dtString.substring(startPos,pos),10); if(day.toString() == "NaN") return false; startPos = pos + 1; //get month i = 0; do { pos = dtString.indexOf(gDelim[i], startPos); i++ } while ((pos == -1) && (i < gDelim.length)); if (pos == -1)return false; month = parseInt(dtString.substring(startPos,pos),10); if(month.toString() == "NaN") return false; startPos = pos + 1; if ((month < 1) || (month > 12)) return false; if ((day < 1) || (day > monthArray[month])) return false; //get year year = parseInt(dtString.substring(startPos,dtString.length),10); if(year.toString() == "NaN") return false; yearlen=(dtString.substring(startPos,dtString.length)) if (yearlen.length != 4) { return false; } //check for leap year if ((month == 2) && (day == 29)) { if ((((year % 400) == 0) || (((year % 4) == 0) && ((year % 100) != 0))) == false) { return false; } } //if we've gotten this far, return true //return true; if (validateDate(pFieldObject.value,"W","P")) { //alert('Date is Valid'); return true;} else { //alert('Date is Invalid or Out of Range'); return false;} } function valDateFmt(datefmt) { myOption = -1; for (i=0; i 0) {result += fld.charAt(i); if (fld.charAt(i) != " ") c = result.length;}}return result.substr(0,c);} var numb = '0123456789'; function isValid(parm,val) {if (parm == "") return true; for (i=0; i -1) dd = dd.substr(0,n); n = dd.lastIndexOf('nd'); if (n > -1) dd = dd.substr(0,n); n = dd.lastIndexOf('rd'); if (n > -1) dd = dd.substr(0,n); n = dd.lastIndexOf('th'); if (n > -1) dd = dd.substr(0,n); n = dd.lastIndexOf(','); if (n > -1) dd = dd.substr(0,n); n = mm.lastIndexOf(','); if (n > -1) mm = mm.substr(0,n); if (!isNum(dd)) return false; if (!isNum(yy)) return false; if (!isNum(mm)) { var nn = mm.toLowerCase(); for (var i=1; i < 13; i++) { if (nn == mth[i] || nn == mth[i].substr(0,3)) {mm = i; i = 13;} } } if (!isNum(mm)) return false; dd = parseFloat(dd); mm = parseFloat(mm); yy = parseFloat(yy); if (yy < 100) yy += 2000; if (yy < 1582 || yy > 4881) return false; if (mm == 2 && (yy%400 == 0 || (yy%4 == 0 && yy%100 != 0))) day[mm-1]++; if (mm < 1 || mm > 12) return false; if (dd < 1 || dd > day[mm-1]) return false; t.setDate(dd); t.setMonth(mm-1); t.setFullYear(yy); if (rng == 'p' || rng == 'P') { if (t > today) return false; } else if (rng == 'f' || rng == 'F') { if (t < today) return false; } else if (rng != 'a' && rng != 'A') return false; return true; } //For Range criteria function showErrors1() { //setFieldFocus1(gNumErr1) for(j=0;j<=k-1;j++) { gManErrWindow.document.writeln("" + RangeLabels[j] + "
") gManErrWindow.document.writeln("
") //alert("val"+RangeLabels[j] ) } } function setFieldFocus1(gNumErr1) { if(!(typeof document.forms[0][gNumErr1].type == "undefined" && document.forms[0][gNumErr1].length >0 ) ) { if(document.forms[0][gNumErr1].type == "text") { document.forms[0][gNumErr1].select(); //alert("end") gManErrWindow.blur(); } if(document.forms[0][gNumErr1].type == "hidden") { var tempFieldName; //check if a rich text field tempFieldName = gNumErr1.substring(2, gNumErr1.length) if(fieldPresent(tempFieldName)) { gNumErr1 = tempFieldName } } document.forms[0][gNumErr1][0].focus() gManErrWindow.blur(); } else { document.forms[0][gNumErr1][0].focus() gManErrWindow.blur(); } }