/* Raghavender Hariharan -- 4/22/2008 ERP-00000-33507 -- Added condition so that page number are not converted to the particular number format hence avoiding the number format exception NOTE: This is a generic fix so this works for all the page where a page number column in included. Added new method isValidConfirm_Set_Password_login and isValidConfirm_Set_Password_security for SW10.1 req10 */ function getMessages(message, paramList) { if (paramList != null) { for(var i = 0; i < paramList.length; i++) { var index = message.indexOf("#"); if (index != -1) { message = message.substring(0, index) + paramList[i] + message.substring(index + 1, message.length); } } } return message; } function messageUtilImpl () { this.getMessage = getMessages; } var MessageUtil = new messageUtilImpl(); /** * Constants */ var gDateFormatMMDDYYYY = 1; var gDateFormatDDMMYYYY = 2; var gDateFormatType = gDateFormatMMDDYYYY; var gValSpace = " "; var gValUnderscore = "\u005f"; var gValComma = "\u002c"; var gValPeriod = "\u002e"; var gValCurrency = "\u0024"; var gValSeperators = "\u007c\u003a\u003b\u002f\u002d"; var gValSupplierPartSpecialChars = "\u0022\u005f\u002d\u0020\u002f\u0026\u002a\u0023\u0025\u003a"; var gValMinus = "\u002d"; var gValQuotes = "\u0022\u0027\u0060"; var gValBraces = "\u0028\u0029\u007b\u007d\u005b\u005d\u003c\u003e"; var gValOtherSpChars = "\u0021\u007e\u0040\u0023\u0025\u005e\u0026\u002a\u002b\u003f"; var gValAllSpecial = gValSpace + gValUnderscore + gValComma + gValPeriod + gValCurrency + gValSeperators + gValQuotes + gValBraces + gValOtherSpChars + gValMinus; var gValAlphaCaps = "ABCDEFGHIJKLMNOPQRSTUVWXYZÀ??ÂÃÄÅÆÇÈÉÊËÌ??Î????ÑÒÓÔÕÖ×ØÙÚÛÜ??Þ?ß???"; var gValAlphaSmall = "abcdefghijklmnopqrstuvwxyzàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ???"; var gValNumbers = "0123456789"; var gbFwdSlashChars = "/"; var gbBwdSlashChars = "\\"; var gbNotNullable = false; var gbNullable = true; /** * Validation functions. */ /** * No documentation yet. */ function isValidSpecialIncluded( fld, // the field that needs to be validated isNullable, // can the field be null minLen, // what is the Min Length of the text, assuming its not null maxLen, // what is the max length of the text includedChars, // what chars to exclude from the text fldName ) // a generic error message for the field, Other messages will be tacked on { var temp = trim(fld); if ( isNull ( fld, isNullable, "", fldName) == false) { return false; } if (fld.value.length == 0) { return true; // if nulls are allowed and it is null then just return } if ( isCorrectLength (fld, minLen, maxLen, fldName) == false ) { return false; } for ( var i = 0 ; i < fld.value.length; i++) { if( (includedChars.indexOf(fld.value.charAt(i)) > -1) == false) { var msg = MessageUtil.getMessage("\u0049\u006e\u0020\u0023\u0020\u0074\u0068\u0065\u0020\u0063\u0068\u0061\u0072\u0061\u0063\u0074\u0065\u0072\u0020\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u006c\u006c\u006f\u0077\u0065\u0064\u002e", new Array(fldName, fld.value.charAt(i))); return validateAlert ( fld, "", msg); } } return true; } function isValidSpecialIncludedNoTrim( fld, // the field that needs to be validated isNullable, // can the field be null minLen, // what is the Min Length of the text, assuming its not null maxLen, // what is the max length of the text includedChars, // what chars to exclude from the text fldName ) // a generic error message for the field, Other messages will be tacked on { if ( isNull ( fld, isNullable, "", fldName) == false) { return false; } if (fld.value.length == 0) { return true; // if nulls are allowed and it is null then just return } if(isNullable == false && (isNull ( fld, isNullable, "", fldName) == true ) && (fld.value.toLowerCase()=="null")) { //If "NULL" or "null" string is entered var msg = MessageUtil.getMessage("\u0054\u0068\u0065\u0020\u0076\u0061\u006c\u0075\u0065\u0020\u006f\u0066\u0020\u0023\u0020\u0063\u0061\u006e\u006e\u006f\u0074\u0020\u0062\u0065\u0020\u004e\u0055\u004c\u004c\u002e", new Array( fldName)); return validateAlert ( fld, "", msg ); } if ( isCorrectLength (fld, minLen, maxLen, fldName) == false ) { return false; } for ( var i = 0 ; i < fld.value.length; i++) { if( (includedChars.indexOf(fld.value.charAt(i)) > -1) == false) { var msg = MessageUtil.getMessage("\u0049\u006e\u0020\u0023\u0020\u0074\u0068\u0065\u0020\u0063\u0068\u0061\u0072\u0061\u0063\u0074\u0065\u0072\u0020\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u006c\u006c\u006f\u0077\u0065\u0064\u002e", new Array(fldName, fld.value.charAt(i))); return validateAlert ( fld, "", msg); } } return true; } function isValidSpecialExcludedNoTrim( fld, // the field that needs to be validated isNullable, // can the field be null minLen, // what is the Min Length of the text, assuming its not null maxLen, // what is the max length of the text excludedChars, // what chars to exclude from the text fldName ) // a generic error message for the field, Other messages will be tacked on { var temp = fld.value; if ( isNull ( fld, isNullable, "", fldName) == false) { return false; } if (fld.value.length == 0) { return true; // if nulls are allowed and it is null then just return } if ( isCorrectLength (fld, minLen, maxLen, fldName) == false) { return false; } for ( var i = 0 ; i < fld.value.length; i++) { if(excludedChars.indexOf(fld.value.charAt(i)) > -1) { var msg = MessageUtil.getMessage("\u0049\u006e\u0020\u0023\u0020\u0074\u0068\u0065\u0020\u0063\u0068\u0061\u0072\u0061\u0063\u0074\u0065\u0072\u0020\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u006c\u006c\u006f\u0077\u0065\u0064\u002e", new Array(fldName, fld.value.charAt(i))); return validateAlert ( fld, "", msg ); } } return true; } function isValidTextArea ( fld, // the field that needs to be validated isNullable, // can the field be null maxLen, // what is the max length of the text fldName ) // a generic error message for the field, Other messages will be tacked on { if ( isNullable == false && (fld.innerHTML.length == 0) ) { var msg = MessageUtil.getMessage("\u0054\u0068\u0065\u0020\u0023\u0020\u0063\u0061\u006e\u006e\u006f\u0074\u0020\u0062\u0065\u0020\u0065\u006d\u0070\u0074\u0079\u002e", new Array( fldName)); alert(msg); return false; } if (fld.innerHTML.length == 0) { return true; // if nulls are allowed and it is null then just return } if ( fld.innerHTML.length > maxLen) { var msg = MessageUtil.getMessage("\u0054\u0068\u0065\u0020\u0023\u0020\u0063\u0061\u006e\u006e\u006f\u0074\u0020\u0062\u0065\u0020\u006d\u006f\u0072\u0065\u0020\u0074\u0068\u0061\u006e\u0020\u0023\u0020\u0063\u0068\u0061\u0072\u0061\u0063\u0074\u0065\u0072\u0073\u0020\u006c\u006f\u006e\u0067", new Array(fldName, maxLen)); alert(msg); return false; } return true; } /** * No documentation yet. */ function isValidSpecialExcluded( fld, // the field that needs to be validated isNullable, // can the field be null minLen, // what is the Min Length of the text, assuming its not null maxLen, // what is the max length of the text excludedChars, // what chars to exclude from the text fldName ) // a generic error message for the field, Other messages will be tacked on { var temp = trim(fld); if ( isNull ( fld, isNullable, "", fldName) == false ) { return false; } if (fld.value.length == 0) { return true; // if nulls are allowed and it is null then just return } if ( isCorrectLength (fld, minLen, maxLen, fldName) == false) { return false; } for ( var i = 0 ; i < fld.value.length; i++) { if(excludedChars.indexOf(fld.value.charAt(i)) > -1) { var msg = MessageUtil.getMessage("\u0049\u006e\u0020\u0023\u0020\u0074\u0068\u0065\u0020\u0063\u0068\u0061\u0072\u0061\u0063\u0074\u0065\u0072\u0020\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u006c\u006c\u006f\u0077\u0065\u0064\u002e", new Array(fldName, fld.value.charAt(i))); return validateAlert ( fld, "", msg); } } return true; } function determineFldName(fld, fldName){ if(fld.fldName != null && fld.fldName != "") { fldName = fld.fldName; } return fldName; } /** * No documentation yet. */ function isValidAlphaNumeric( fld, // the field that needs to be validated isNullable, // can the field be null minLen, // what is the Min Length of the text, assuming its not null maxLen, // what is the max length of the text fldName) // a generic error message for the field, Other messages will be tacked on { var temp = trim(fld); fldName = determineFldName(fld,fldName); if ( isNull ( fld, isNullable, "", fldName) == false) { return false; } if (fld.value.length == 0) { return true; // if nulls are allowed and it is null then just return } if ( isCorrectLength (fld, minLen, maxLen, fldName) == false) { return false; } for ( var i = 0 ; i < fld.value.length; i++) { var individualChar = fld.value.charAt(i); // check to see if the char is not in the caps, small, numbers, and that it's still within ASCII (255) range // then, if all this is correct, then fail. if( gValAlphaCaps.indexOf(individualChar) == -1 && gValAlphaSmall.indexOf(individualChar) == -1 && gValNumbers.indexOf(individualChar) == -1 && individualChar<'\u0100') { var msg = MessageUtil.getMessage("\u004e\u006f\u0020\u0073\u0070\u0065\u0063\u0069\u0061\u006c\u0020\u0063\u0068\u0061\u0072\u0061\u0063\u0074\u0065\u0072\u0073\u0020\u0061\u006c\u006c\u006f\u0077\u0065\u0064\u0020\u0069\u006e\u0020\u0023", new Array(fldName)); return validateAlert ( fld, "", msg); } } return true; } /** * No documentation yet. */ function isValidAnyChar( fld, // the field that needs to be validated isNullable, // can the field be null minLen, // what is the Min Length of the text, assuming its not null maxLen, // what is the max length of the text fldName ) // a generic error message for the field, Other messages will be tacked on { var frm = fld.form; var temp = trim(fld); if ( isNull ( fld, isNullable, "", fldName) == false) { return false; } if (fld.value.length == 0) { return true; // if nulls are allowed and it is null then just return } if(isNullable == false && (isNull ( fld, isNullable, "", fldName) == true ) && (fld.value.toLowerCase()=="null")) { //If "NULL" or "null" string is entered var msg = MessageUtil.getMessage("\u0054\u0068\u0065\u0020\u0076\u0061\u006c\u0075\u0065\u0020\u006f\u0066\u0020\u0023\u0020\u0063\u0061\u006e\u006e\u006f\u0074\u0020\u0062\u0065\u0020\u004e\u0055\u004c\u004c\u002e", new Array( fldName)); return validateAlert ( fld, "", msg ); } if(frm.name != "importCertificate") { if ( isCorrectLength (fld, minLen, maxLen, fldName) == false ) { return false; } } return true; } /** * This function is used if the field on the form you want to validate * should be an Int. * * @param fld, the field that needs to be validated * @param isNullable, can the field be null * @param minVal, what is the Min Value of the number * @param maxVal, what is the Max Value of the number * @param DefaultValue, if lefy blank, this will be put in * @param fldName, a generic error message for the field, messages will be tacked on for uniform error messages. */ function isValidNumericInt( fld, isNullable, minVal, maxVal, DefaultValue, fldName ) { return isValidNumericIntCustomMsg ( fld, isNullable, minVal, maxVal, DefaultValue, fldName, ""); } /** * This function allows use to customize messages when needed. * One should usually call isValidNumericInt instead of this function. * * Note: customerMsg == "" will run the default message. * * @param fld, the field that needs to be validated * @param isNullable, can the field be null * @param minVal, what is the Min Value of the number * @param maxVal, what is the Max Value of the number * @param DefaultValue, if lefy blank, this will be put in * @param fldName, a generic error message for the field, messages will be tacked on for uniform error messages. * @param customMsg, a custom message that is needed very very rarely. */ function isValidNumericIntCustomMsg ( fld, isNullable, minVal, maxVal, DefaultValue, fldName, customMsg){ var temp = trim(fld); if ( isNull ( fld, isNullable, DefaultValue, fldName) == false) { return false; } if (fld.value.length == 0) { return true; // if nulls are allowed and it is null then just return } var testNum = fld.value; if(!validatePattern(testNum)){ //displayPattern(fld); var msg = MessageUtil.getMessage("\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u004e\u0075\u006d\u0062\u0065\u0072\u0020\u0046\u006f\u0072\u006d\u0061\u0074", new Array(fldName,",")); return validateAlert ( fld, DefaultValue, msg); } else{ testNum = convertToNumber(testNum); if ( isNaN ( testNum ) == false) // it is a number { var testInt = parseInt (testNum); var testDouble = parseFloat (testNum); //alert(testNum); if (testInt != testDouble || testNum.indexOf(".") != -1 ) { var msg = MessageUtil.getMessage("\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0061\u006e\u0020\u0069\u006e\u0074\u0065\u0067\u0065\u0072\u0020\u0028\u006e\u006f\u0020\u0064\u0065\u0063\u0069\u006d\u0061\u006c\u0029", new Array(fldName)); return validateAlert ( fld, DefaultValue, msg); } else { if ( testNum < minVal || testNum > maxVal) { if(customMsg != "") { return validateAlert ( fld, DefaultValue, customMsg ); } else { var msg = MessageUtil.getMessage("\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0062\u0065\u0074\u0077\u0065\u0065\u006e\u0020\u0023\u0020\u0061\u006e\u0064\u0020\u0023", new Array(fldName, minVal, maxVal)); return validateAlert ( fld, DefaultValue, msg ); } } } } else { var msg = MessageUtil.getMessage("\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0061\u006e\u0020\u0069\u006e\u0074\u0065\u0067\u0065\u0072", new Array(fldName)); return validateAlert ( fld, DefaultValue, msg); } } // ERP-00000-33507.sn if(fldName != "Page Number"){ displayLongPattern(fld); }else{ fld.value = convertToNumber(fld.value); } return true; //ERP-00000-33507.en } function isValidNumericQtyFloat( fld, isNullable, minVal, maxVal, DefaultValue, fldName) { return isValidNumericQtyFloatCustomMsg ( fld, isNullable, minVal, maxVal, DefaultValue, fldName, ""); } function isValidNumericQtyFloatCustomMsg ( fld, isNullable, minVal, maxVal, DefaultValue, fldName, customMsg){ var temp = trim(fld); if ( isNull ( fld, isNullable, DefaultValue, fldName) == false) { return false; } if (fld.value.length == 0) { return true; // if nulls are allowed and it is null then just return } var testNum = fld.value; if(isNaN(convertToNumber(testNum))) { if(customMsg != "") { return validateAlert ( fld, DefaultValue, customMsg ); } else { var msg = MessageUtil.getMessage("\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0062\u0065\u0074\u0077\u0065\u0065\u006e\u0020\u0023\u0020\u0061\u006e\u0064\u0020\u0023", new Array(fldName, minVal, maxVal)); return validateAlert ( fld, DefaultValue, msg); } } if(!validatePattern(testNum)){ var msg = MessageUtil.getMessage("\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u004e\u0075\u006d\u0062\u0065\u0072\u0020\u0046\u006f\u0072\u006d\u0061\u0074", new Array(fldName,",")); return validateAlert ( fld, DefaultValue, msg); } else{ testNum = convertToNumber(testNum); if ( isNaN ( testNum ) == false) // it is a number { var testDouble = parseFloat (testNum); var str=testDouble.toString(); if ( testNum < minVal || testNum > maxVal) { if(customMsg != ""){ return validateAlert ( fld, DefaultValue, customMsg ); } else { var msg = MessageUtil.getMessage("\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0062\u0065\u0074\u0077\u0065\u0065\u006e\u0020\u0023\u0020\u0061\u006e\u0064\u0020\u0023", new Array(fldName, minVal, maxVal)); return validateAlert ( fld, DefaultValue, msg ); } } //if((fldName=="\u0051\u0075\u0061\u006e\u0074\u0069\u0074\u0079") && (str.indexOf(".") != -1)){ var pos=str.indexOf(".") var sub=str.substring(pos+1,pos+10) var len=sub.length; if(len > 5 && (str.indexOf(".") != -1)){ var msg; if(fld.name == "totalClaimAmount") { msg =MessageUtil.getMessage("\u0054\u006f\u0074\u0061\u006c\u0020\u0043\u006c\u0061\u0069\u006d\u0020\u0041\u006d\u006f\u0075\u006e\u0074\u0020\u0073\u0068\u006f\u0075\u006c\u0064\u0020\u006e\u006f\u0074\u0020\u0065\u0078\u0063\u0065\u0065\u0064\u0020\u0035\u0020\u0064\u0065\u0063\u0069\u006d\u0061\u006c\u0020\u0070\u006c\u0061\u0063\u0065\u0073", new Array(fldName, minVal, maxVal)); return validateAlert ( fld, DefaultValue, msg ); } else if(fld.name == "ClaimAmt") { msg =MessageUtil.getMessage("\u0041\u006d\u006f\u0075\u006e\u0074\u0020\u0073\u0068\u006f\u0075\u006c\u0064\u0020\u006e\u006f\u0074\u0020\u0065\u0078\u0063\u0065\u0065\u0064\u0020\u0035\u0020\u0064\u0065\u0063\u0069\u006d\u0061\u006c\u0020\u0070\u006c\u0061\u0063\u0065\u0073", new Array(fldName, minVal, maxVal)); return validateAlert ( fld, DefaultValue, msg ); } else { msg =MessageUtil.getMessage("\u0051\u0075\u0061\u006e\u0074\u0069\u0074\u0079\u0020\u0073\u0068\u006f\u0075\u006c\u0064\u0020\u006e\u006f\u0074\u0020\u0065\u0078\u0063\u0065\u0065\u0064\u0020\u0035\u0020\u0064\u0065\u0063\u0069\u006d\u0061\u006c\u0020\u0070\u006c\u0061\u0063\u0065\u0073", new Array(fldName, minVal, maxVal)); return validateAlert ( fld, DefaultValue, msg ); } } //} } else { if(customMsg != "") { return validateAlert ( fld, DefaultValue, customMsg ); } else { var msg = MessageUtil.getMessage("\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0062\u0065\u0074\u0077\u0065\u0065\u006e\u0020\u0023\u0020\u0061\u006e\u0064\u0020\u0023", new Array(fldName, minVal, maxVal)); return validateAlert ( fld, DefaultValue, msg); } } } displayDoublePattern(fld); return true; } function isValidNumericUnitPriceFloat ( fld, isNullable, minVal, maxVal, DefaultValue, fldName, customMsg){ var temp = trim(fld); if ( isNull ( fld, isNullable, DefaultValue, fldName) == false) { return false; } if (fld.value.length == 0) { return true; // if nulls are allowed and it is null then just return } var testNum = fld.value; if(isNaN(convertToNumber(testNum))) { if(customMsg != "") { return validateAlert ( fld, DefaultValue, customMsg ); } else { var msg = MessageUtil.getMessage("\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0062\u0065\u0074\u0077\u0065\u0065\u006e\u0020\u0023\u0020\u0061\u006e\u0064\u0020\u0023", new Array(fldName, minVal, maxVal)); return validateAlert ( fld, DefaultValue, msg); } } if(!validatePattern(testNum)){ var msg = MessageUtil.getMessage("\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u004e\u0075\u006d\u0062\u0065\u0072\u0020\u0046\u006f\u0072\u006d\u0061\u0074", new Array(fldName,",")); return validateAlert ( fld, DefaultValue, msg); } else{ testNum = convertToNumber(testNum); if ( isNaN ( testNum ) == false) // it is a number { var testDouble = parseFloat (testNum); var str=testDouble.toString(); if ( testNum < minVal || testNum > maxVal) { if(customMsg != ""){ return validateAlert ( fld, DefaultValue, customMsg ); } else { var msg = MessageUtil.getMessage("\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0062\u0065\u0074\u0077\u0065\u0065\u006e\u0020\u0023\u0020\u0061\u006e\u0064\u0020\u0023", new Array(fldName, minVal, maxVal)); return validateAlert ( fld, DefaultValue, msg ); } } var pos=str.indexOf(".") var sub=str.substring(pos+1,pos+10) var len=sub.length; if(len > 5 && (str.indexOf(".") != -1)){ msg =MessageUtil.getMessage("\u0055\u006e\u0069\u0074\u0020\u0050\u0072\u0069\u0063\u0065\u0020\u0073\u0068\u006f\u0075\u006c\u0064\u0020\u006e\u006f\u0074\u0020\u0065\u0078\u0063\u0065\u0065\u0064\u0020\u0035\u0020\u0064\u0065\u0063\u0069\u006d\u0061\u006c\u0020\u0070\u006c\u0061\u0063\u0065\u0073", new Array(fldName, minVal, maxVal)); return validateAlert ( fld, DefaultValue, msg ); } } else { if(customMsg != "") { return validateAlert ( fld, DefaultValue, customMsg ); } else { var msg = MessageUtil.getMessage("\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0062\u0065\u0074\u0077\u0065\u0065\u006e\u0020\u0023\u0020\u0061\u006e\u0064\u0020\u0023", new Array(fldName, minVal, maxVal)); return validateAlert ( fld, DefaultValue, msg); } } } displayDoublePattern(fld); return true; } /** * @param fld, the field that needs to be validated * @param isNullable, can the field be null * @param minVal, what is the Min Value of the number * @param maxVal, what is the Max Value of the number * @param DefaultValue, if lefy blank, this will be put in * @param fldName, a generic error message for the field, messages will be tacked on for uniform error messages. */ function isValidNumericFloat( fld, isNullable, minVal, maxVal, DefaultValue, fldName ) { return isValidNumericFloatCustomMsg ( fld, isNullable, minVal, maxVal, DefaultValue, fldName, ""); } /** * This function allows use to customize messages when needed. * One should usually call isValidNumericFloat instead of this function. * * Note: customMsg == "" will run the default message. * * @param fld, the field that needs to be validated * @param isNullable, can the field be null * @param minVal, what is the Min Value of the number * @param maxVal, what is the Max Value of the number * @param DefaultValue, if lefy blank, this will be put in * @param fldName, a generic error message for the field, messages will be tacked on for uniform error messages. * @param customMsg, a custom message that is needed very very rarely. */ function isValidNumericFloatCustomMsg ( fld, isNullable, minVal, maxVal, DefaultValue, fldName, customMsg){ var temp = trim(fld); if ( isNull ( fld, isNullable, DefaultValue, fldName) == false) { return false; } if (fld.value.length == 0) { return true; // if nulls are allowed and it is null then just return } var testNum = fld.value; if(isNaN(convertToNumber(testNum))) { if(customMsg != "") { return validateAlert ( fld, DefaultValue, customMsg ); } else { var msg = MessageUtil.getMessage("\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0062\u0065\u0074\u0077\u0065\u0065\u006e\u0020\u0023\u0020\u0061\u006e\u0064\u0020\u0023", new Array(fldName, minVal, maxVal)); return validateAlert ( fld, DefaultValue, msg); } } if(!validatePattern(testNum)){ var msg = MessageUtil.getMessage("\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u004e\u0075\u006d\u0062\u0065\u0072\u0020\u0046\u006f\u0072\u006d\u0061\u0074", new Array(fldName,",")); return validateAlert ( fld, DefaultValue, msg); } else{ testNum = convertToNumber(testNum); if ( isNaN ( testNum ) == false) // it is a number { var testDouble = parseFloat (testNum); var str=testDouble.toString(); if((fldName=="\u0050\u0061\u0072\u0074\u0020\u0057\u0065\u0069\u0067\u0068\u0074") && (str.indexOf(".") != -1)){ var pos=str.indexOf(".") var sub=str.substring(pos+1,pos+10) var len=sub.length; if(len > 6){ alert("\u0050\u0061\u0072\u0074\u0020\u0057\u0065\u0069\u0067\u0068\u0074\u0020\u0073\u0068\u006f\u0075\u006c\u0064\u0020\u006e\u006f\u0074\u0020\u0065\u0078\u0063\u0065\u0065\u0064\u0020\u0036\u0020\u0064\u0065\u0063\u0069\u006d\u0061\u006c\u0020\u0070\u006c\u0061\u0063\u0065\u0073"); fld.focus(); return false; } } if ( testNum < minVal || testNum > maxVal) { if(customMsg != ""){ return validateAlert ( fld, DefaultValue, customMsg ); } else { var msg = MessageUtil.getMessage("\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0062\u0065\u0074\u0077\u0065\u0065\u006e\u0020\u0023\u0020\u0061\u006e\u0064\u0020\u0023", new Array(fldName, minVal, maxVal)); return validateAlert ( fld, DefaultValue, msg ); } } } else { if(customMsg != "") { return validateAlert ( fld, DefaultValue, customMsg ); } else { var msg = MessageUtil.getMessage("\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0062\u0065\u0074\u0077\u0065\u0065\u006e\u0020\u0023\u0020\u0061\u006e\u0064\u0020\u0023", new Array(fldName, minVal, maxVal)); return validateAlert ( fld, DefaultValue, msg); } } } displayDoublePattern(fld); return true; } /** * @param fld, the field that needs to be validated * @param isNullable, can the field be null * @param minVal, what is the Min Value of the number * @param maxVal, what is the Max Value of the number * @param decimalPlaces, what is the Max number of decimal places * @param DefaultValue, if lefy blank, this will be put in * @param fldName, a generic error message for the field, messages will be tacked on for uniform error messages. */ function isValidNumericCustomFloat( fld, isNullable, minVal, maxVal, decimalPlaces ,DefaultValue, fldName ) { return isValidNumericCustomFloatCustomMsg ( fld, isNullable, minVal, maxVal, decimalPlaces , DefaultValue, fldName); } /** * This function allows use to customize messages when needed. * One should usually call isValidNumericFloat instead of this function. * * Note: customMsg == "" will run the default message. * * @param fld, the field that needs to be validated * @param isNullable, can the field be null * @param minVal, what is the Min Value of the number * @param maxVal, what is the Max Value of the number * @param decimalPlaces, what is the Max number of decimal places * @param DefaultValue, if lefy blank, this will be put in * @param fldName, a generic error message for the field, messages will be tacked on for uniform error messages. * @param customMsg, a custom message that is needed very very rarely. */ function isValidNumericCustomFloatCustomMsg ( fld, isNullable, minVal, maxVal, decimalPlaces ,DefaultValue, fldName, customMsg){ var temp = trim(fld); if ( isNull ( fld, isNullable, DefaultValue, fldName) == false) { return false; } if (fld.value.length == 0) { return true; // if nulls are allowed and it is null then just return } var testNum = fld.value; if(!validatePattern(testNum)){ var msg = MessageUtil.getMessage("\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u004e\u0075\u006d\u0062\u0065\u0072\u0020\u0046\u006f\u0072\u006d\u0061\u0074", new Array(fldName,",")); return validateAlert ( fld, DefaultValue, msg); } else{ testNum = convertToNumber(testNum); if ( isNaN ( testNum ) == false) // it is a number { var testDouble = parseFloat (testNum); var str=testDouble.toString(); var pos=str.indexOf(".") if(pos > 0){ var sub=str.substring(pos+1,pos+10) var len=sub.length; if(len > parseInt(decimalPlaces)){ var customMsg = MessageUtil.getMessage("\u004e\u0075\u006d\u0062\u0065\u0072\u0020\u0073\u0068\u006f\u0075\u006c\u0064\u0020\u006e\u006f\u0074\u0020\u0065\u0078\u0063\u0065\u0065\u0064\u0020\u0023\u0020\u0064\u0065\u0063\u0069\u006d\u0061\u006c\u0020\u0070\u006c\u0061\u0063\u0065\u0073", new Array(""+decimalPlaces+"")); alert(customMsg); fld.focus(); return false; } } if ( testNum < minVal || testNum > maxVal) { var msg = MessageUtil.getMessage("\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0062\u0065\u0074\u0077\u0065\u0065\u006e\u0020\u0023\u0020\u0061\u006e\u0064\u0020\u0023", new Array(fldName, minVal, maxVal)); return validateAlert ( fld, DefaultValue, msg ); } } else { var msg = MessageUtil.getMessage("\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0062\u0065\u0074\u0077\u0065\u0065\u006e\u0020\u0023\u0020\u0061\u006e\u0064\u0020\u0023", new Array(fldName, minVal, maxVal)); return validateAlert ( fld, DefaultValue, msg); } } displayDoublePattern(fld); return true; } /** * No documentation yet. */ function isValidTextNumericInt( fld, // the field that needs to be validated isNullable, // can the field be null minLen, // what is the Min Length of the text, assuming its not null maxLen, // what is the max length of the text fldName ) // a generic error message for the field, Other messages will be tacked on { var fldValue = convertToNumber(fld.value); var temp = trim(fld); if ( isNull ( fld, isNullable,"", fldName) == false) { return false; } if (fldValue.length == 0) { return true; // if nulls are allowed and it is null then just return } if ( isCorrectLength (fld, minLen, maxLen, fldName) == false) { return false; } for ( var i = 0 ; i < fldValue.length; i++) { var individualChar = fldValue.charAt(i); if ( gValNumbers.indexOf(individualChar) == -1) { var msg = MessageUtil.getMessage("\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u006e\u0075\u006d\u0065\u0072\u0069\u0063\u0020\u002d\u0020\u004e\u006f\u0020\u006c\u0065\u0074\u0074\u0065\u0072\u0073\u0020\u006f\u0072\u0020\u0073\u0070\u0065\u0063\u0069\u0061\u006c\u0020\u0063\u0068\u0061\u0072\u0061\u0063\u0074\u0065\u0072\u0073" , new Array(fldName)); return validateAlert ( fld, "", msg ); } } return true; } /** * No documentation yet. */ function isValidDUNS( fld, // the field that needs to be validated isNullable, // can the field be null fldName ) // a generic error message for the field, Other messages will be tacked on { var intDigitSum; var intTransform; intDigitSum = 0; var temp = trim(fld); if (temp == "00-000-0000") { var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0044\u0055\u004e\u0053\u0020\u002d\u0020\u0020\u0066\u0061\u0069\u006c\u0073\u0020\u0063\u0068\u0065\u0063\u006b\u0020\u0064\u0069\u0067\u0069\u0074\u0020\u0074\u0065\u0073\u0074", new Array(fldName)); return validateAlert ( fld, "", msg); } if ( isNull ( fld, isNullable,"", fldName) == false) { return false; } if (fld.value.length == 0) { return true; // if nulls are allowed and it is null then just return } var DUNS = fld.value; if ('#' == DUNS.charAt(0)) { // enter secret validation routine for companies who refuse to use DUNS if (11 == DUNS.length) { var bIsNum = true; for (var i = 1; i < 11; ++i) { if (DUNS.charAt(i) < "0" || DUNS.charAt(i) > "9") { bIsNum = false; } } if (bIsNum) { return true; // passed back-door validation } } } DUNS = DUNS.replace(/-/g,''); if ( DUNS.length != 9 ) { var msg = MessageUtil.getMessage("\u0023\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0065\u0078\u0061\u0063\u0074\u006c\u0079\u0020\u0039\u0020\u0063\u0068\u0061\u0072\u0061\u0063\u0074\u0065\u0072\u0073\u0020\u0069\u006e\u0020\u006c\u0065\u006e\u0067\u0074\u0068\u0020\u0028\u0065\u0078\u0063\u006c\u0075\u0064\u0069\u006e\u0067\u0020\u0061\u006e\u0079\u0020\u0068\u0079\u0070\u0068\u0065\u006e\u0073\u0029", new Array(fldName)); return validateAlert ( fld, "", msg ); } for (var i = 0; i < 9; i++) { if (DUNS.charAt(i) < "0" || DUNS.charAt(i) > "9") { fld.value = DUNS; var msg = MessageUtil.getMessage("\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u006e\u0075\u006d\u0065\u0072\u0069\u0063\u0020\u002d\u0020\u006e\u006f\u0020\u006c\u0065\u0074\u0074\u0065\u0072\u0073\u0020\u006f\u0072\u0020\u0073\u0070\u0065\u0063\u0069\u0061\u006c\u0020\u0063\u0068\u0061\u0072\u0061\u0063\u0074\u0065\u0072\u0073\u0020\u0028\u0023\u0029", new Array(fldName , DUNS.charAt(i))); return validateAlert ( fld, "", msg ); } if (i % 2 == 0) { intDigitSum += parseInt(convertToNumber(DUNS.charAt(i))) } else { intTransform = parseInt(convertToNumber(DUNS.charAt(i))) * 2; if (intTransform > 9) { intTransform -= 9; } intDigitSum += intTransform; } } /***** Removed checksum digit validation - ERP-00000-69593 if (intDigitSum % 5 != 0 && intDigitSum % 5 != 1) { fld.value = DUNS; var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0044\u0055\u004e\u0053\u0020\u002d\u0020\u0020\u0066\u0061\u0069\u006c\u0073\u0020\u0063\u0068\u0065\u0063\u006b\u0020\u0064\u0069\u0067\u0069\u0074\u0020\u0074\u0065\u0073\u0074", new Array(fldName)); return validateAlert ( fld, "", msg); } *********/ var temp = DUNS.charAt (0) + DUNS.charAt (1) + "-" + DUNS.charAt (2) + DUNS.charAt (3) + DUNS.charAt (4) + "-" + DUNS.charAt (5) + DUNS.charAt (6) + DUNS.charAt (7) + DUNS.charAt (8); fld.value = temp; if (fld.value == "00-000-0000") { var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0044\u0055\u004e\u0053\u0020\u002d\u0020\u0020\u0066\u0061\u0069\u006c\u0073\u0020\u0063\u0068\u0065\u0063\u006b\u0020\u0064\u0069\u0067\u0069\u0074\u0020\u0074\u0065\u0073\u0074", new Array(fldName)); return validateAlert ( fld, "", msg); } return true; } /** * No documentation yet. */ function isValidRegistrationId( fld, // The first password feild isNullable, // can the field be null fldName ) // the name of the field { return isValidAlphaNumeric( fld, isNullable,6,30,fldName); } /** * No documentation yet. */ function isValidRegistrationKey( fld, // The first password feild isNullable, // can the field be null fldName ) // the name of the field { return isValidPwd( fld, isNullable, fldName); } /** * No documentation yet. */ function isValidUserID( fld, // The field itself isNullable, // can the field be null fldName ) // the name of the field { return isValidAnyChar( fld, isNullable, 6, 30,fldName); } /** * No documentation yet. */ function isValidUserId( fld, // The field isNullable, // can the field be null fldName ) // the name of the field { return isValidAnyChar( fld, isNullable, 6, 13,fldName); } /** * No documentation yet. */ function isValidPwd( fld, // The first password feild isNullable, // can the field be null fldName ) // the name of the field { return isValidAnyChar( fld, isNullable, 6, 13,fldName); } /** * No documentation yet. */ function isValidFTPPwd( fld, // The first password feild isNullable, // can the field be null fldName ) // the name of the field { return isValidAnyChar( fld, isNullable, 1, 100, fldName); } /** * No documentation yet. */ function isValidConfirm_FTP_Password( fld1, // The first password feild fld2, // The second or confirm password feild fldName1,// the name of the first password fldName2)// the name of the Second passwrod { if ( fld1.value == "" && fld2.value =="") { return true; } if ( isValidFTPPwd (fld1, gbNotNullable, fldName1) == false) { fld1.value = ""; fld2.value = ""; return false; } if ( isValidFTPPwd (fld2, gbNotNullable, fldName2) == false) { fld2.value = ""; return false; } if ( fld1.value != fld2.value) { fld2.value = ""; var msg = MessageUtil.getMessage("\u0023\u0020\u0061\u006e\u0064\u0020\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0074\u0068\u0065\u0020\u0073\u0061\u006d\u0065", new Array(fldName1, fldName2)); return validateAlert ( fld1, "", msg ); } return true; } /** * No documentation yet. */ function isGreaterNextSerialNum ( fld1, // The nex serial number fld2, // Tha last serial number fldName1,// the name of the first field fldName2)// the name of the Second fields { var nNext = parseFloat(convertToNumber(fld1.value)); var nLast = parseFloat(convertToNumber(fld2.value)); if ( nLast < nNext ) { var msg = MessageUtil.getMessage("\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0067\u0072\u0065\u0061\u0074\u0065\u0072\u0020\u0074\u0068\u0061\u006e\u0020\u0023", new Array(fldName2, fldName1)); validateAlert( fld1,"",msg ); return false; } return true; } /** * No documentation yet. */ function isValidConfirm_Password( fld_Orig, // The origanal password fld_New, // The new password fld_Confirm, // The conformation password fld_Name_Orig, // the name of the field fld_Name_New, // the name of the field fld_Name_Confirm)// the name of the field { if ( fld_Orig.value == "" && fld_New.value =="" && fld_Confirm.value =="") { return true; } if ( isValidPwd (fld_Orig, gbNotNullable, fld_Name_Orig) == false) { fld_Orig.value = ""; return false; } if ( isValidPwd (fld_New, gbNotNullable, fld_Name_New) == false) { fld_New.value = ""; fld_Confirm.value = ""; return false; } if ( isValidPwd (fld_Confirm, gbNotNullable, fld_Name_Confirm) == false) { fld_Confirm.value = ""; return false; } if ( fld_New.value != fld_Confirm.value) { fld_Confirm.value = ""; var msg = MessageUtil.getMessage("\u0023\u0020\u0061\u006e\u0064\u0020\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0074\u0068\u0065\u0020\u0073\u0061\u006d\u0065", new Array(fld_Name_New, fld_Name_Confirm)); return validateAlert ( fld_New, "", msg ); } return true; } /** * No documentation yet. */ function isValidConfirm_Set_Password( fld_New, // The new password fld_Confirm, // The conformation password fld_Name_New, // the name of the field fld_Name_Confirm)// the name of the field { if (fld_New.value == "" && fld_Confirm.value =="") { return true; } if ( fld_New.value != fld_Confirm.value) { fld_Confirm.value = ""; var msg = MessageUtil.getMessage( "\u0023\u0020\u0061\u006e\u0064\u0020\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0074\u0068\u0065\u0020\u0073\u0061\u006d\u0065", new Array(fld_Name_New, fld_Name_Confirm)); return validateAlert ( fld_New, "", msg ); } return true; } //raghava.sn function isValidConfirm_Set_Password_login( fld_New, // The new password fld_Confirm, // The conformation password fld_Current, // The current password fld_Name_New, // the name of the field fld_Name_Confirm, // the name of the field fld_Name_Current) //the name of the field { if(fld_Current.value == "") { var msg = MessageUtil.getMessage( "\u0054\u0068\u0065\u0020\u0023\u0020\u0069\u0073\u0020\u006d\u0061\u006e\u0064\u0061\u0074\u006f\u0072\u0079\u0020\u0077\u0068\u0065\u006e\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0069\u006e\u0067\u0020\u0061\u0020\u0023", new Array(fld_Name_Current, fld_Name_New)); return validateAlert ( fld_Current, "", msg ); } else if(fld_Current.value != "" && fld_New.value != "" && fld_Confirm.value == ""){ var msg = MessageUtil.getMessage( "\u0054\u0068\u0065\u0020\u0023\u0020\u0069\u0073\u0020\u006d\u0061\u006e\u0064\u0061\u0074\u006f\u0072\u0079\u0020\u0077\u0068\u0065\u006e\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0069\u006e\u0067\u0020\u0061\u0020\u0023", new Array(fld_Name_Confirm, fld_Name_New)); return validateAlert ( fld_Confirm, "", msg ); } else if((fld_Current.value != "" && fld_New.value == "" && fld_Confirm.value != "") || (fld_Current.value != "" && fld_New.value == "" && fld_Confirm.value == "")){ var msg = MessageUtil.getMessage( "\u0054\u0068\u0065\u0020\u0023\u0020\u0069\u0073\u0020\u006d\u0061\u006e\u0064\u0061\u0074\u006f\u0072\u0079\u0020\u0077\u0068\u0065\u006e\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0069\u006e\u0067\u0020\u0061\u0020\u0023", new Array( fld_Name_New,fld_Name_Current)); return validateAlert ( fld_New, "", msg ); } else if ( fld_New.value != fld_Confirm.value){ fld_Confirm.value = ""; var msg = MessageUtil.getMessage( "\u0023\u0020\u0064\u006f\u0065\u0073\u0020\u006e\u006f\u0074\u0020\u006d\u0061\u0074\u0063\u0068\u0020\u0074\u0068\u0065\u0020\u0023\u0020", new Array(fld_Name_Confirm,fld_Name_New )); return validateAlert ( fld_Confirm, "", msg ); } return isValidPwd( fld_New, gbNotNullable, "\u004e\u0065\u0077\u0020\u0050\u0061\u0073\u0073\u0077\u006f\u0072\u0064"); } function isValidConfirm_Set_Password_security( fld_New, // The new password fld_Confirm, // The conformation password fld_Current, // The current password fld_Name_New, // the name of the field fld_Name_Confirm, // the name of the field fld_Name_Current, userType,userTypefromDB) //the name of the field { if(userType == null){ // this if loop is written for the Edit user profile because it doesnt have the userType. // only validate confirm field exists if the user is trying to update password. if((fld_New.value.length != 0 || fld_Confirm.value.length != 0) && (fld_Current.value.length == 0)){ var msg = MessageUtil.getMessage( "\u0054\u0068\u0065\u0020\u0023\u0020\u0069\u0073\u0020\u006d\u0061\u006e\u0064\u0061\u0074\u006f\u0072\u0079\u002e", new Array(fld_Name_Current)); return validateAlert ( fld_Current, "", msg ); } else if(fld_New.value.length == 0 && fld_Confirm.value.length != 0){ var msg = MessageUtil.getMessage( "\u0054\u0068\u0065\u0020\u0023\u0020\u0069\u0073\u0020\u006d\u0061\u006e\u0064\u0061\u0074\u006f\u0072\u0079\u0020\u0077\u0068\u0065\u006e\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0069\u006e\u0067\u0020\u0061\u0020\u0023", new Array( fld_Name_New,fld_Name_Confirm)); return validateAlert ( fld_New, "", msg ); } else if(fld_New.value.length != 0 && fld_Confirm.value.length == 0){ var msg = MessageUtil.getMessage( "\u0054\u0068\u0065\u0020\u0023\u0020\u0069\u0073\u0020\u006d\u0061\u006e\u0064\u0061\u0074\u006f\u0072\u0079\u0020\u0077\u0068\u0065\u006e\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0069\u006e\u0067\u0020\u0061\u0020\u0023", new Array( fld_Name_Confirm,fld_Name_New)); return validateAlert ( fld_Confirm, "", msg ); } else if ( fld_New.value != fld_Confirm.value){ fld_Confirm.value = ""; var msg = MessageUtil.getMessage( "\u0023\u0020\u0064\u006f\u0065\u0073\u0020\u006e\u006f\u0074\u0020\u006d\u0061\u0074\u0063\u0068\u0020\u0074\u0068\u0065\u0020\u0023\u0020", new Array(fld_Name_Confirm,fld_Name_New )); return validateAlert ( fld_Confirm, "", msg ); } return true; } // end if(userTpe==null) else if(userType.value != "contact"){ //else condition is for the other cases except the userType as contact where there will be no validations for password // only validate confirm field exists if the user is trying to update password. if((fld_New.value.length != 0 || fld_Confirm.value.length != 0) && fld_Current != null && fld_Current.value.length == 0){ var msg = MessageUtil.getMessage( "\u0054\u0068\u0065\u0020\u0023\u0020\u0069\u0073\u0020\u006d\u0061\u006e\u0064\u0061\u0074\u006f\u0072\u0079\u002e", new Array(fld_Name_Current)); return validateAlert ( fld_Current, "", msg ); } else if(fld_New.value.length == 0 && fld_Confirm.value.length != 0){ var msg = MessageUtil.getMessage( "\u0054\u0068\u0065\u0020\u0023\u0020\u0069\u0073\u0020\u006d\u0061\u006e\u0064\u0061\u0074\u006f\u0072\u0079\u0020\u0077\u0068\u0065\u006e\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0069\u006e\u0067\u0020\u0061\u0020\u0023", new Array( fld_Name_New,fld_Name_Confirm)); return validateAlert ( fld_New, "", msg ); } else if(fld_New.value.length != 0 && fld_Confirm.value.length == 0){ var msg = MessageUtil.getMessage( "\u0054\u0068\u0065\u0020\u0023\u0020\u0069\u0073\u0020\u006d\u0061\u006e\u0064\u0061\u0074\u006f\u0072\u0079\u0020\u0077\u0068\u0065\u006e\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0069\u006e\u0067\u0020\u0061\u0020\u0023", new Array( fld_Name_Confirm,fld_Name_New)); return validateAlert ( fld_Confirm, "", msg ); } else if ( fld_New.value != fld_Confirm.value){ fld_Confirm.value = ""; var msg = MessageUtil.getMessage( "\u0023\u0020\u0064\u006f\u0065\u0073\u0020\u006e\u006f\u0074\u0020\u006d\u0061\u0074\u0063\u0068\u0020\u0074\u0068\u0065\u0020\u0023\u0020", new Array(fld_Name_Confirm,fld_Name_New )); return validateAlert ( fld_Confirm, "", msg ); } else if(fld_New.value.length == 0 && userTypefromDB == null){ return isValidPwd(fld_New, gbNotNullable, "\u004e\u0065\u0077\u0020\u0050\u0061\u0073\u0073\u0077\u006f\u0072\u0064"); } else if(userTypefromDB != null && userTypefromDB.value == "contact" && (userType.value == "user" || userType.value == "both")) { if(fld_New.value.length == 0) { return isValidPwd(fld_New, gbNotNullable, "\u004e\u0065\u0077\u0020\u0050\u0061\u0073\u0073\u0077\u006f\u0072\u0064"); } else if (fld_New.value.length != 0 && fld_Confirm.value.length == 0) { var msg = MessageUtil.getMessage( "\u0054\u0068\u0065\u0020\u0023\u0020\u0069\u0073\u0020\u006d\u0061\u006e\u0064\u0061\u0074\u006f\u0072\u0079\u0020\u0077\u0068\u0065\u006e\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0069\u006e\u0067\u0020\u0061\u0020\u0023", new Array( fld_Name_Confirm,fld_Name_New)); return validateAlert ( fld_Confirm, "", msg ); } else if(fld_New.value != fld_Confirm.value) { fld_Confirm.value = ""; var msg = MessageUtil.getMessage( "\u0023\u0020\u0064\u006f\u0065\u0073\u0020\u006e\u006f\u0074\u0020\u006d\u0061\u0074\u0063\u0068\u0020\u0074\u0068\u0065\u0020\u0023\u0020", new Array(fld_Name_Confirm,fld_Name_New )); return validateAlert ( fld_Confirm, "", msg ); } } return true; } // end if(userType!=contact) } function isValidConfirm_Delete_Password_security( fld_Current, fld_Name_Current,userType,adminYn) { if(adminYn != null && adminYn.value == "true") { if(userType == null || userType.value != "contact") { if(fld_Current != null && fld_Current.value == "") { var msg = MessageUtil.getMessage( "\u0054\u0068\u0065\u0020\u0023\u0020\u0069\u0073\u0020\u006d\u0061\u006e\u0064\u0061\u0074\u006f\u0072\u0079\u0020\u0077\u0068\u0065\u006e\u0020\u0064\u0065\u006c\u0065\u0074\u0069\u006e\u0067\u0020\u0061\u0020\u0041\u0064\u006d\u0069\u006e\u0020\u0055\u0073\u0065\u0072\u002e", new Array(fld_Name_Current)); return validateAlert ( fld_Current, "", msg ); } return true; } return true; } return true; } //raghava.en /** * No documentation yet. */ function isValidConfirm_Registration_Key( fld_Key, // The registration Key fld_Confirm, // The conformation registration key fld_Name_Key, // the name of the field fld_Name_Confirm)// the name of the field { if ( isValidPwd (fld_Key, gbNotNullable, fld_Name_Key) == false) { fld_Key.value = ""; fld_Confirm.value = ""; return false; } if ( isValidPwd (fld_Confirm, gbNotNullable, fld_Name_Confirm) == false) { fld_Confirm.value = ""; return false; } if ( fld_Key.value != fld_Confirm.value) { fld_Confirm.value = ""; var msg = MessageUtil.getMessage("\u0023\u0020\u0061\u006e\u0064\u0020\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0074\u0068\u0065\u0020\u0073\u0061\u006d\u0065", new Array(fld_Name_Key, fld_Name_Confirm)); return validateAlert ( fld_Key, "", msg ); } return true; } /** * No documentation yet. */ function isValidIPAddress( fld, // the field that needs to be validated isNullable, // can the field be null fldName ) // a generic error message for the field, Other messages will be tacked on { var temp = trim(fld); if ( isNull ( fld, isNullable,"", fldName) == false) { return false; } if (fld.value.length == 0) { return true; // if nulls are allowed and it is null then just return } var tempStr = fld.value; var count = 0; var tempNumber; var endIndex =0; if (tempStr.indexOf (" ") >= 0) { var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0049\u0050\u0020\u0041\u0064\u0064\u0072\u0065\u0073\u0073\u0020\u002d\u0020\u0073\u0070\u0061\u0063\u0065\u0073\u0020\u0061\u0072\u0065\u0020\u006e\u006f\u0074\u0020\u0061\u006c\u006c\u006f\u0077\u0065\u0064\u002e", new Array(fldName)); return validateAlert ( fld, "", msg); } while (endIndex < tempStr.length) { tempStr = tempStr.substr (endIndex); endIndex = tempStr.indexOf ("."); if ( endIndex == -1) { endIndex = tempStr.length; } tempNumber = tempStr.substring (0, endIndex); //Not a valid validation, it works if it is ip address, what if it is a domain name. //if (isNaN ( tempNumber )) //{ // var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0049\u0050\u0020\u0041\u0064\u0064\u0072\u0065\u0073\u0073", new Array(fldName)); // return validateAlert ( fld, "", msg); //} if (Number (tempNumber) < 0 || Number (tempNumber) > 255) { var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0049\u0050\u0020\u0041\u0064\u0064\u0072\u0065\u0073\u0073", new Array(fldName)); return validateAlert ( fld, "", msg); } count = count + 1; endIndex = endIndex +1; } //Not a valid validation, it works if it is ip address, what if it is a domain name. //if (count != 4 ) //{ // var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0049\u0050\u0020\u0041\u0064\u0064\u0072\u0065\u0073\u0073", new Array(fldName)); // return validateAlert ( fld, "", msg); //} return true; } /** * this should be called After the "isValidDate" function */ function isValidDateRange_old( fld_Early, // The early date fld_Late, // the later date fld_Early_Name, // the early dates name fld_Late_Name, // the late dates name bInclusive ) // true means the dates can be the same { var dEarly = toDate_old (fld_Early, fld_Early_Name); var dLate = toDate_old (fld_Late, fld_Late_Name); if (bInclusive) { if (dEarly > dLate) { var msg = MessageUtil.getMessage("\u0054\u0068\u0065\u0020\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0065\u0061\u0072\u006c\u0069\u0065\u0072\u0020\u0074\u0068\u0061\u006e\u0020\u0023", new Array(fld_Early_Name, fld_Late_Name)); return validateAlert ( fld_Early,"",msg); } } else { if (dEarly >= dLate) return validateAlert ( fld_Early,"","The " + fld_Early_Name + " must be earlier than " + fld_Late_Name); } return true; } /** * Documentation not yet available. */ function isValidDate_old( fld, // the field that needs to be validated isNullable, // can the field be null fldName ) // a generic error message for the field, Other messages will be tacked on { if ( isNull ( fld, isNullable, "", fldName) == false) { return false; } if (fld.value.length == 0) { return true; // if nulls are allowed and it is null then just return } var dDate = toDate_old (fld, fldName); if (dDate == false) { return false; } return true; } /** * Documentation not yet available. */ function isValidTime_old( fld, // the field that needs to be validated isNullable, // can the field be null fldName ) // a generic error message for the field, Other messages will be tacked on { // Valid format is "hh:mm" 0 >= hh <= 12, 0>= mm <= 59 if ( isNull ( fld, isNullable, "", fldName) == false) { return false; } if (fld.value.length == 0) { return true; // if nulls are allowed and it is null then just return } if ( fld.value.charAt(2) != ':' || fld.value.length != 5 ) { var msg = MessageUtil.getMessage("\u0023\u0020\u0068\u0061\u0073\u0020\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0074\u0069\u006d\u0065\u0020\u0066\u006f\u0072\u006d\u0061\u0074\u003b\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0074\u0069\u006d\u0065\u0020\u0066\u006f\u0072\u006d\u0061\u0074\u0020\u0069\u0073\u0020\u0048\u0048\u003a\u004d\u004d", new Array(fldName)); return validateAlert ( fld, "", msg ); } var arr = fld.value.split(':'); if (arr.length != 2) { var msg = MessageUtil.getMessage("\u0023\u0020\u0068\u0061\u0073\u0020\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0074\u0069\u006d\u0065\u0020\u0066\u006f\u0072\u006d\u0061\u0074\u003b\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0074\u0069\u006d\u0065\u0020\u0066\u006f\u0072\u006d\u0061\u0074\u0020\u0069\u0073\u0020\u0068\u0068\u003a\u006d\u006d", new Array(fldName)); return validateAlert ( fld, "", msg); } var numhr = parseInt(convertToNumber(arr[0])); if (isNaN(numhr) || numhr < 0 || numhr > 12 ) { // the hour is not a number var msg = MessageUtil.getMessage("\u0023\u0020\u0068\u006f\u0075\u0072\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0076\u0061\u006c\u0075\u0065", new Array(fldName)); return validateAlert ( fld, "", msg); } var nummin = parseInt(convertToNumber(arr[1])); if (isNaN(nummin) || nummin < 0 || nummin > 59 ) { var msg = MessageUtil.getMessage("\u0023\u0020\u006d\u0069\u006e\u0075\u0074\u0065\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0076\u0061\u006c\u0075\u0065", new Array(fldName)); return validateAlert ( fld, "", msg ); } return true; } /** * Documentation not yet available. */ function toDate_old( fld, // the field that needs to be validated fldName ) // a generic error message for the field, Other messages will be tacked on { var temp = trim(fld); var month = 0; var day; var year; var temp1 = 0; var temp2 = 0; var tempChar = ""; var tempYear; var tempInputDate = fld.value var index = 0; // the positions look like // | | | // 1/1/2000 12/12/2000 12122000 // first get the first value, can be day or month depending on format // first char Must be a number tempChar = tempInputDate.charAt (index); if ( tempChar == "") { var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065", new Array(fldName)); return validateAlert ( fld, "", msg); } index = index + 1; if (isNaN(tempChar)) { var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065", new Array(fldName)); return validateAlert ( fld, "", msg); } temp1 = tempChar; // the positions look like // | | | // 1/1/2000 12/12/2000 12122000 // second char can be a number or a delemeter (12120000 or 1/1/2000) tempChar = tempInputDate.charAt (index); if ( tempChar == "") { var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065", new Array(fldName)); return validateAlert ( fld, "", msg); } index = index + 1; if (isNaN(tempChar) == false) // it is a number { temp1 = temp1 + tempChar; tempChar = tempInputDate.charAt (index); if ( tempChar == "") { var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065", new Array(fldName)); return validateAlert ( fld, "", msg); } // if the next char is not a number its a delimeter and should be ignored if (isNaN(tempChar)) { index = index + 1; } } // at this point the first part it finished // the positions look like // | | | // 1/1/2000 12/12/2000 12122000 // now parse the second value tempChar = tempInputDate.charAt (index); if ( tempChar == "") { var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065", new Array(fldName)); return validateAlert ( fld, "", msg); } // the first value of must be a number if (isNaN(tempChar)) { var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065", new Array(fldName)); return validateAlert ( fld, "", msg); } temp2 = tempChar; index = index + 1; tempChar = tempInputDate.charAt (index); if ( tempChar == "") { var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065", new Array(fldName)); return validateAlert ( fld, "", msg); } index = index + 1; // the positions look like // | | | // 1/1/2000 12/12/2000 12122000 // second char can be a number or a delemeter (12120000 or 1/1/2000) if (isNaN(tempChar) == false) // it is a number { temp2 = temp2 + tempChar; tempChar = tempInputDate.charAt (index); if ( tempChar == "") { var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065", new Array(fldName)); return validateAlert ( fld, "", msg); } if (isNaN(tempChar)) { // if the next char is not a number its a delimeter and should be ignored index = index + 1; } } // now the second char is someplete // the positions look like // | | | // 1/1/2000 12/12/2000 12122000 tempYear = tempInputDate.substr (index);// gets from that point to the end if (isNaN(tempYear)) { // the first value of must be a number var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065", new Array(fldName)); return validateAlert ( fld, "", msg); } if (tempYear >= 0 && tempYear < 50) { year = Number (tempYear) + 2000; } else { if (tempYear >=50 && tempYear < 100) { year = Number (tempYear) + 1900; } else { if (tempYear >=1900 && tempYear <2050) { year = tempYear; } else { var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0059\u0065\u0061\u0072", new Array(fldName)); return validateAlert ( fld, "", msg); } } } // ok, the year is done, now for the dates switch(gDateFormatType) { case gDateFormatMMDDYYYY: month = temp1; day = temp2; break; case gDateFormatDDMMYYYY: month = temp2; day = temp1; break; default: var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0067\u006c\u006f\u0062\u0061\u006c\u0020\u0064\u0061\u0074\u0065\u0020\u0066\u006f\u0072\u006d\u0061\u0074", new Array(fldName)); return validateAlert ( fld, "", msg ); } // now that we have all of the parts, lets check the date itself var testDate = new Date ( year, month-1, day);// the date control will accept any close to valid date but will // convert the date to make it work so 13/1/1999 will be converted // to 1/1/2000 var d = testDate.getDate (); var m = testDate.getMonth () +1; // if ( year < 2000) // var y = testDate.getYear() + 1900; // else // var y = testDate.getYear(); // // alert ("number 2 year " + year + " - " + y); // alert ("number 3 month " + month + " - " + m); // alert ("number 4 day " + day + " - " + d); if (year < 2000) { if (year != (testDate.getYear () + 1900)) { // getYear returns 2 digits for 1999 and under var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065", new Array(fldName)); return validateAlert ( fld, "", msg); } } else { if (year != (testDate.getYear ())) { // getYear returns 4 digits for 2000 and over var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065", new Array(fldName)); return validateAlert ( fld, "", msg); } } if (month != (testDate.getMonth () + 1)) { var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065", new Array(fldName)); return validateAlert ( fld, "", msg); } if (day != testDate.getDate ()) { var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065", new Array(fldName)); return validateAlert ( fld, "", msg); } // ok the date it correct, lets put it back out in the correct format switch(gDateFormatType) { case gDateFormatMMDDYYYY: fld.value = month + "-" + day + "-" + year; break; case gDateFormatDDMMYYYY: fld.value = day + "-" + month + "-" + year; break; default: var msg = MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0067\u006c\u006f\u0062\u0061\u006c\u0020\u0064\u0061\u0074\u0065\u0020\u0066\u006f\u0072\u006d\u0061\u0074", new Array(fldName)); return validateAlert ( fld, "", msg); } return testDate; } /** * E-Mail - all characters allowed. No Spaces. Must have a @ with text on either side. * Must have a "." on the right side of the @ with text on either side of it. */ function isValidEmail( fld, // the field that needs to be validated isNullable, // can the field be null fldName ) // a generic error message for the field, Other messages will be tacked on { var index; var inputVal = fld.value; if ( isNull ( fld, isNullable,"", fldName) == false) { return false; } if (inputVal.length == 0) { return true; } if ( inputVal.indexOf ("@") == inputVal.length-1 || inputVal.indexOf ("@") == 0 || inputVal.indexOf ("@") < 1 || inputVal.indexOf ("@") != inputVal.lastIndexOf ("@") || inputVal.length < 4 || // a@.b inputVal.indexOf(".") == -1 || inputVal.indexOf(".") < 1 || // its not the first char inputVal.lastIndexOf(".") > inputVal.length-2 || // its the last char or beyond inputVal.indexOf ("@") > inputVal.lastIndexOf (".") || inputVal.indexOf(" ") != -1 ) { var msg = MessageUtil.getMessage("\u0023\u0020\u0041\u0064\u0064\u0072\u0065\u0073\u0073\u0020\u0066\u006f\u0072\u006d\u0061\u0074\u0020\u0069\u0073\u0020\u0069\u006e\u0076\u0061\u006c\u0069\u0064", new Array(fldName)); return validateAlert ( fld, "", msg); } return true; } /** * No documentation yet available. */ function isValidComboSel( fld, // the field that needs to be validated fldName ) // a generic error message for the field, Other messages will be tacked on { // check for select of less than zero if (fld.length < 0 ) { var msg = MessageUtil.getMessage("\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0068\u0061\u0076\u0065\u0020\u0061\u0074\u0020\u006c\u0065\u0061\u0073\u0074\u0020\u0031\u0020\u0073\u0065\u006c\u0065\u0063\u0074\u0069\u006f\u006e", new Array(fldName)); return validateAlert ( fld, "", msg); } return true; } /** * No documentation yet available. */ function isValidComboSelFirstBlank( fld, // the field that needs to be validated fldName ) // a generic error message for the field, Other messages will be tacked on { // check for select of less than zero var atLeastOneValueValid = false; for ( var i = 0 ; i < fld.length; i++) { if (fld.options[i].value != -1) { atLeastOneValueValid = true; } } if(atLeastOneValueValid == false) { var msg = MessageUtil.getMessage("\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0068\u0061\u0076\u0065\u0020\u0061\u0074\u0020\u006c\u0065\u0061\u0073\u0074\u0020\u0031\u0020\u0073\u0065\u006c\u0065\u0063\u0074\u0069\u006f\u006e", new Array(fldName)); return validateAlert ( fld, "", msg); } return atLeastOneValueValid; } /** * No documentation yet available. */ function isValidComboSelection (fld, fldName) { if (fld.selectedIndex < 0 ) { var msg = MessageUtil.getMessage("\u0050\u006c\u0065\u0061\u0073\u0065\u0020\u0073\u0065\u006c\u0065\u0063\u0074\u0020\u0061\u0020\u0023", new Array(fldName)); return validateAlert (msg); } return true; } /** * Helper functions for the validation */ /** * No documentation yet available. */ function validateAlert( fld, // the field that needs to be validated defaultValue, // can the field be null alertmsg ) // a generic error message for the field, Other messages will be tacked on { window.event.returnValue = false; if(fld.type != 'hidden'){ try { fld.focus(); } catch(e) { } } alert(alertmsg); if ((fld.type == "text") || (fld.type == "password")) { if (defaultValue != "") { fld.value = defaultValue; } fld.select(); } return false; } /** * No documentation yet available. */ function isNull( fld, // the field that needs to be validated isNullable, // can the field be null DefaultValue, // if lefy blank, this will be put in fldName ) // a generic error message for the field, Other messages will be tacked on { if ( isNullable == false && fld.value.length == 0) { var msg = MessageUtil.getMessage("\u0050\u006c\u0065\u0061\u0073\u0065\u0020\u0065\u006e\u0074\u0065\u0072\u0020\u0074\u0068\u0065\u0020\u0023", new Array(fldName)); return validateAlert ( fld, DefaultValue, msg ); } else { return true; } } /** * This assumes that the nullablility has already been tested for */ function isCorrectLength( fld, // the field that needs to be validated minLen, // Min Length maxLen, // Max Length fldName ) // a generic error message for the field, Other messages will be tacked on { if(fld.value.length > 0) { if(fld.value.length < minLen) { var msg = MessageUtil.getMessage("\u0054\u0068\u0065\u0020\u0023\u0020\u0063\u0061\u006e\u006e\u006f\u0074\u0020\u0062\u0065\u0020\u006c\u0065\u0073\u0073\u0020\u0074\u0068\u0061\u006e\u0020\u0023\u0020\u0063\u0068\u0061\u0072\u0061\u0063\u0074\u0065\u0072\u0073\u0020\u006c\u006f\u006e\u0067", new Array(fldName, minLen)); return validateAlert ( fld, "", msg ); } if(fld.value.length > maxLen) { var msg = MessageUtil.getMessage("\u0054\u0068\u0065\u0020\u0023\u0020\u0063\u0061\u006e\u006e\u006f\u0074\u0020\u0062\u0065\u0020\u006d\u006f\u0072\u0065\u0020\u0074\u0068\u0061\u006e\u0020\u0023\u0020\u0063\u0068\u0061\u0072\u0061\u0063\u0074\u0065\u0072\u0073\u0020\u006c\u006f\u006e\u0067", new Array(fldName, maxLen)); return validateAlert ( fld, "", msg ); } } return true; } /** * This should be in java script lib, but its not */ function trim(fld) { var t = fld.value; ok = true; while ((t.length >0) && (t.charAt(0) == " " || // space t.charAt(0) == "\b"|| // backspace t.charAt(0) == "\t"|| // tab t.charAt(0) == "\n"|| // newline t.charAt(0) == "\r"|| // return t.charAt(0) == "\f" ) ) // formfeed { t = t.substring(1, t.length); } while ( t.length >0 && (t.charAt(t.length-1) == " " || // space t.charAt(t.length-1) == "\b"|| // backspace t.charAt(t.length-1) == "\t"|| // tab t.charAt(t.length-1) == "\n"|| // newline t.charAt(t.length-1) == "\r"|| // return t.charAt(t.length-1) == "\f")) // formfeed { t = t.substring(0, t.length-1); } fld.value = t; return t; } /** * */ function isValidOptionalAddress(form){ if(form.line1Tx.value == "" || form.line1Tx.value.length == 0) { return true; } if( isValidAnyChar (form.line1Tx, gbNotNullable, 1, 30, "\u0041\u0064\u0064\u0072\u0065\u0073\u0073\u0020\u004c\u0069\u006e\u0065\u0020\u0031") && isValidAnyChar (form.line2Tx, gbNullable, 1, 30, "\u0041\u0064\u0064\u0072\u0065\u0073\u0073\u0020\u004c\u0069\u006e\u0065\u0020\u0032") && isValidAnyChar (form.line3Tx, gbNullable, 1, 30, "\u0041\u0064\u0064\u0072\u0065\u0073\u0073\u0020\u004c\u0069\u006e\u0065\u0020\u0033") && isValidAnyChar (form.cityTx, gbNotNullable, 1, 25, "\u0043\u0069\u0074\u0079") && isValidAnyChar (form.postalCodeTx, gbNotNullable, 1, 10, "\u0050\u006f\u0073\u0074\u0061\u006c\u0020\u0043\u006f\u0064\u0065") && isValidComboSel ( form.ezCountryId, "\u0043\u006f\u0075\u006e\u0074\u0072\u0079\u0020\u0044\u0065\u0073\u0063\u0072\u0069\u0070\u0074\u0069\u006f\u006e") && isValidComboSel ( form.ezStateProvinceId, "\u0053\u0074\u0061\u0074\u0065\u0020\u006f\u0072\u0020\u0050\u0072\u006f\u0076\u0069\u006e\u0063\u0065") && isValidComboSel ( form.ezTimeZoneId, "\u0054\u0069\u006d\u0065\u0020\u005a\u006f\u006e\u0065") ) { return true; } return false; } /** * Used on the user screen. */ function isValidAdminRole(admin, role){ if((admin.checked == false) && (role.disabled == false) && (role.value == -1)) { var msg = "\u0041\u0020\u0072\u006f\u006c\u0065\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0073\u0065\u006c\u0065\u0063\u0074\u0065\u0064\u002e"; return validateAlert ( admin, "", msg); } else { return true; } } function isValidSSOUserID(frm) { if (frm.ssoRequired.checked) { if (isValidAnyChar (frm.ssoId, gbNotNullable, 1, 30, "\u0053\u0053\u004f\u0020\u0049\u0044") == false) { return false; } return true; } } var isAddressNullable = gbNotNullable; /** * This method is used to validate the address. */ function validateAddressFrm(frm) { if( isValidAnyChar(frm.line1Tx, isAddressNullable, 1, 30, "\u0041\u0064\u0064\u0072\u0065\u0073\u0073") == false ) { return false; } if (frm.ezStateProvinceId.value == "") { // now, if any required flds are non- blank then they must all be non- blank if (( frm.line1Tx.value.length > 0 ) || ( frm.cityTx.value.length > 0 ) || ( frm.ezCountryId.value != -1 ) || ( frm.ezTimeZoneId.value != -1 )) { if (( frm.line1Tx.value.length > 0 ) && ( frm.cityTx.value.length > 0 ) && ( frm.ezCountryId.value != -1 ) && ( frm.ezTimeZoneId.value != -1 )) { return true; } else { if(frm.line1Tx.value.length == 0) { var msg = "\u0050\u006c\u0065\u0061\u0073\u0065\u0020\u0065\u006e\u0074\u0065\u0072\u0020\u0061\u006e\u0020\u0061\u0064\u0064\u0072\u0065\u0073\u0073"; return validateAlert(frm.line1Tx, "", msg); } if(frm.cityTx.value.length == 0) { var msg = "\u0050\u006c\u0065\u0061\u0073\u0065\u0020\u0065\u006e\u0074\u0065\u0072\u0020\u0061\u0020\u0063\u0069\u0074\u0079"; return validateAlert(frm.cityTx, "", msg); } return false; } } } else { // If any required flds are non- blank then they must all be non- blank if (frm.line1Tx.value.length > 0 || frm.cityTx.value.length > 0 || frm.postalCodeTx.value.length > 0 || frm.ezCountryId.value != -1 || frm.ezTimeZoneId.value != -1 || frm.ezStateProvinceId.value != -1 ) { if ( frm.line1Tx.value.length > 0 && frm.postalCodeTx.value.length > 0 && frm.cityTx.value.length > 0 && frm.ezCountryId.value != -1 && frm.ezTimeZoneId.value != -1 && ((frm.ezStateProvinceId.length > 1 && frm.ezStateProvinceId.value != -1) || (frm.ezStateProvinceId.length == 1 && frm.ezStateProvinceId.value == -1) ) ) { if (frm.ezStateProvinceId.length == 1 && frm.ezStateProvinceId.value == -1){ frm.ezStateProvinceId[frm.ezStateProvinceId.selectedIndex].value = ''; } return true; } else { if(frm.line1Tx.value.length == 0) { var msg = "\u0050\u006c\u0065\u0061\u0073\u0065\u0020\u0065\u006e\u0074\u0065\u0072\u0020\u0061\u006e\u0020\u0061\u0064\u0064\u0072\u0065\u0073\u0073"; return validateAlert(frm.line1Tx, "", msg); } if(frm.cityTx.value.length == 0) { var msg = "\u0050\u006c\u0065\u0061\u0073\u0065\u0020\u0065\u006e\u0074\u0065\u0072\u0020\u0061\u0020\u0063\u0069\u0074\u0079"; return validateAlert(frm.cityTx, "", msg); } if(frm.ezCountryId.value < 0) { var msg = "\u0050\u006c\u0065\u0061\u0073\u0065\u0020\u0073\u0065\u006c\u0065\u0063\u0074\u0020\u0061\u0020\u0043\u006f\u0075\u006e\u0074\u0072\u0079"; return validateAlert(frm.ezCountryId, "", msg); } if(frm.ezStateProvinceId != null && frm.ezStateProvinceId.length > 1 && frm.ezStateProvinceId.value < 0) { var msg = "\u0050\u006c\u0065\u0061\u0073\u0065\u0020\u0073\u0065\u006c\u0065\u0063\u0074\u0020\u0061\u0020\u0053\u0074\u0061\u0074\u0065\u0020\u006f\u0072\u0020\u0050\u0072\u006f\u0076\u0069\u006e\u0063\u0065"; return validateAlert(frm.ezStateProvinceId, "", msg); } if(frm.postalCodeTx.value.length == 0) { var msg = "\u0050\u006c\u0065\u0061\u0073\u0065\u0020\u0065\u006e\u0074\u0065\u0072\u0020\u0061\u0020\u0050\u006f\u0073\u0074\u0061\u006c\u0020\u0043\u006f\u0064\u0065"; return validateAlert(frm.postalCodeTx, "", msg); } if(frm.ezTimeZoneId.value < 0) { var msg = "\u0050\u006c\u0065\u0061\u0073\u0065\u0020\u0073\u0065\u006c\u0065\u0063\u0074\u0020\u0061\u0020\u0054\u0069\u006d\u0065\u0020\u005a\u006f\u006e\u0065"; return validateAlert(frm.ezTimeZoneId, "", msg); } return false; } } } return true; } /** * This sets whether or not the address is required on this page */ function setAddressNullablity(isNullable){ if(isNullable != null){ isAddressNullable = isNullable; } } /** * Used in shipment status console filter screen */ function isCheckPointSelected(frm){ if (frm.gttCheckpointId.options[frm.gttCheckpointId.selectedIndex].value == -1){ frm.action = "../gtt/shipmentDetailsUpdate"; } else{ frm.action = "../gtt/checkpointsedit"; } } function receiptHistoryPartSelect(frm,fromWhere) { if ( frm.ptPartMstrId[frm.ptPartMstrId.selectedIndex].value == '-1' ) { if ( fromWhere == 'fromPartList' ) { frm.pullSignal.disabled = true; frm.modelYear.disabled = true; frm.engChgLvl.disabled = true; } frm.action = frm.allPartAction.value; } else { if ( fromWhere == 'fromPartList' ) { frm.pullSignal.value = ''; frm.pullSignal.disabled = false; frm.modelYear.value = ''; frm.modelYear.disabled = false; frm.engChgLvl.value = ''; frm.engChgLvl.disabled = false; } frm.action = frm.singlePartAction.value; } } function receiptAndShipHistoryResetFields(frm) { frm.pullSignal.value = ''; frm.modelYear.value = ''; frm.engChgLvl.value = ''; frm.ptPartMstrId.value = '-1'; } /* * Used in Shipment History Filter screen */ function shipHistoryPartSelect(frm,fromWhere) { isValidDateRangeFullComparisions(frm.startDate, true, 'Ship Date From', frm.endDate, true, 'Ship Date To', frm.dateFormat); /* if ( frm.startDate.value != '' && frm.endDate.value != '') { if (frm.startDate.value > frm.endDate.value){ //ERP-00000-33355 s.o isValidDateRange(frm.startDate, frm.endDate, 'Ship Date From', 'Ship Date To', false, 3); ERP-00000-33355 e.o //ERP-00000-33355 s.n isValidDateRange(frm.startDate, frm.endDate, 'Ship Date From', 'Ship Date To', false, frm.dateFormat); //ERP-00000-33355 e.n } } */ if ( frm.ptPartMstrId[frm.ptPartMstrId.selectedIndex].value == '-1' ) { if ( fromWhere == 'fromPartList' ) { frm.pullSignal.disabled = true; frm.modelYear.disabled = true; frm.engChgLvl.disabled = true; } frm.action ='../shipper/listShipPartSummary'; } else { if ( fromWhere == 'fromPartList' ) { frm.pullSignal.value = ''; frm.pullSignal.disabled = false; frm.modelYear.value = ''; frm.modelYear.disabled = false; frm.engChgLvl.value = ''; frm.engChgLvl.disabled = false; } //frm.action ='../shipper/listShipPartDetail'; frm.action ='../shipper/listShipPartSummary'; } } function validateShipper(frm,shipperIdSelected,shipperIdText) { if(shipperIdSelected == -1 && shipperIdText.length > 40 )//when shipper number has been entered but its length has to checked { alert('\u0054\u0068\u0065\u0020\u0053\u0068\u0069\u0070\u0070\u0065\u0072\u0020\u0049\u0044\u0020\u0063\u0061\u006e\u0020\u006e\u006f\u0074\u0020\u0062\u0065\u0020\u006d\u006f\u0072\u0065\u0020\u0074\u0068\u0061\u006e\u0020\u0034\u0030\u0020\u0063\u0068\u0061\u0072\u0061\u0063\u0074\u0065\u0072\u0073\u0020\u006c\u006f\u006e\u0067'); frm.shipperIdText.focus(); frm.action=''; return false; } if(shipperIdSelected == -1 && shipperIdText == '') { alert('\u0050\u006c\u0065\u0061\u0073\u0065\u0020\u0065\u006e\u0074\u0065\u0072\u0020\u0061\u0020\u0053\u0068\u0069\u0070\u0070\u0065\u0072\u0020\u0049\u0044'); frm.shipperIdText.focus(); frm.action=''; return false; } else { return true; } } function validateDeleteInvoiceDiscount(frm) { var notSelected = true; for (k = 0; k < frm.length; k++){ if(frm.elements[k].type == "checkbox" && frm.elements[k].name == "bilProdInvoiceAdj") { if(frm.elements[k].checked) { notSelected = false; break; } } } if(notSelected == false) { var answer = confirm ('\u0044\u006f\u0020\u0059\u006f\u0075\u0020\u0077\u0061\u006e\u0074\u0020\u0074\u006f\u0020\u0064\u0065\u006c\u0065\u0074\u0065\u0020\u0044\u0069\u0073\u0063\u006f\u0075\u006e\u0074\u003f'); if (!answer) { return; } else{ frm.action = 'deleteInvoiceDiscountSurcharge'; frm.submit(); } } else{ alert('\u0050\u006c\u0065\u0061\u0073\u0065\u0020\u0073\u0065\u006c\u0065\u0063\u0074\u0020\u0061\u006e\u0020\u0049\u006e\u0076\u006f\u0069\u0063\u0065\u0020\u0044\u0069\u0073\u0063\u006f\u0075\u006e\u0074\u0020\u0074\u006f\u0020\u0064\u0065\u006c\u0065\u0074\u0065'); return; } } function validateDeleteInvoiceSurcharge(frm) { var notSelected = true; for (k = 0; k < frm.length; k++){ if(frm.elements[k].type == "checkbox" && frm.elements[k].name == "bilProdInvoiceAdj") { if(frm.elements[k].checked) { notSelected = false; break; } } } if(notSelected == false) { var answer = confirm ('\u0044\u006f\u0020\u0059\u006f\u0075\u0020\u0077\u0061\u006e\u0074\u0020\u0074\u006f\u0020\u0064\u0065\u006c\u0065\u0074\u0065\u0020\u0053\u0075\u0072\u0063\u0068\u0061\u0072\u0067\u0065\u003f\u0020'); if (!answer) { return; } else{ frm.action = 'deleteInvoiceDiscountSurcharge'; frm.submit(); } } else{ alert('\u0050\u006c\u0065\u0061\u0073\u0065\u0020\u0073\u0065\u006c\u0065\u0063\u0074\u0020\u0061\u006e\u0020\u0049\u006e\u0076\u006f\u0069\u0063\u0065\u0020\u0053\u0075\u0072\u0063\u0068\u0061\u0072\u0067\u0065\u0020\u0074\u006f\u0020\u0064\u0065\u006c\u0065\u0074\u0065'); return; } } function validateDeleteInvoiceLineItem(frm) { var notSelected = true; for (k = 0; k < frm.length; k++){ if(frm.elements[k].type == "checkbox" && frm.elements[k].name == "bilProdInvoiceLi") { if(frm.elements[k].checked) { notSelected = false; break; } } } if(notSelected == false) { var answer = confirm ('\u0044\u006f\u0020\u0059\u006f\u0075\u0020\u0077\u0061\u006e\u0074\u0020\u0074\u006f\u0020\u0064\u0065\u006c\u0065\u0074\u0065\u0020\u004c\u0069\u006e\u0065\u0020\u0049\u0074\u0065\u006d\u003f\u0020'); if (!answer) { return; } else{ frm.action = 'deleteInvoiceLineItem'; frm.submit(); } } else{ alert('\u0050\u006c\u0065\u0061\u0073\u0065\u0020\u0073\u0065\u006c\u0065\u0063\u0074\u0020\u0061\u0020\u004c\u0069\u006e\u0065\u0020\u0049\u0074\u0065\u006d\u0020\u0074\u006f\u0020\u0064\u0065\u006c\u0065\u0074\u0065'); return; } } /** * This function is used to delete Supplier Note */ function validateDeleteSupplierNote(frm) { var answer = confirm ('\u0044\u006f\u0020\u0059\u006f\u0075\u0020\u0077\u0061\u006e\u0074\u0020\u0074\u006f\u0020\u0064\u0065\u006c\u0065\u0074\u0065\u0020\u0053\u0075\u0070\u0070\u006c\u0069\u0065\u0072\u0020\u004e\u006f\u0074\u0065\u003f\u0020'); if (!answer) { return; } else{ frm.action = 'deleteSupplierNote'; frm.submit(); } } /** * This function is used to delete Transportation cost */ function validateDeleteTransCost(frm) { var answer = confirm ('\u0044\u006f\u0020\u0059\u006f\u0075\u0020\u0077\u0061\u006e\u0074\u0020\u0074\u006f\u0020\u0064\u0065\u006c\u0065\u0074\u0065\u0020\u0053\u0068\u0069\u0070\u0070\u0069\u006e\u0067\u0020\u0061\u006e\u0064\u0020\u0048\u0061\u006e\u0064\u006c\u0069\u006e\u0067\u0020\u0063\u006f\u0073\u0074\u003f'); if (!answer) { return; } else{ frm.action = 'deleteTransCost '; frm.submit(); } } /* *this function is use for viewInvoice from ui.xsl.html.PARTBILHISTINVLIST */ function viewInvoice( facility, shipTo, shipFrom,shipper, invoiceNoTx, invoiceNo,invoiceDtStr,invoiceStatusId, modeFlag, userType) { if(invoiceStatusId == 7 || invoiceStatusId == 5 || (invoiceStatusId == 2 && userType == 2 ) ){ document.PartBilHistInvListForm.viewEditFlag.value = 'view'; } else{ document.PartBilHistInvListForm.viewEditFlag.value = 'edit'; } document.PartBilHistInvListForm.syntaxNm.value = 'PRODINVCREATE'; document.PartBilHistInvListForm.ezFacilityId.value = facility; document.PartBilHistInvListForm.ezShipToId.value = shipTo; document.PartBilHistInvListForm.ezShipFromId.value = shipFrom; document.PartBilHistInvListForm.shipperIdTx.value = shipper; document.PartBilHistInvListForm.invoiceId.value = invoiceNo; document.PartBilHistInvListForm.invoiceIdTx.value = invoiceNoTx; document.PartBilHistInvListForm.invoiceDtStr.value = invoiceDtStr; document.PartBilHistInvListForm.modeFlag.value = modeFlag; document.PartBilHistInvListForm.action='../../billing/prodInvoice/showProdInv'; document.PartBilHistInvListForm.submit(); } function validateDeleteInvoiceTax(frm) { var notSelected = true; for (k = 0; k < frm.length; k++){ if(frm.elements[k].type == "checkbox" && frm.elements[k].name == "bilProdInvoiceTax") { if(frm.elements[k].checked) { notSelected = false; break; } } } if(notSelected == false) { var answer = confirm ('\u0044\u006f\u0020\u0059\u006f\u0075\u0020\u0077\u0061\u006e\u0074\u0020\u0074\u006f\u0020\u0064\u0065\u006c\u0065\u0074\u0065\u0020\u0049\u006e\u0076\u006f\u0069\u0063\u0065\u0020\u0054\u0061\u0078\u003f'); if (!answer) { return; } else{ frm.action = 'deleteInvoiceTax'; frm.submit(); } } else{ alert('\u0050\u006c\u0065\u0061\u0073\u0065\u0020\u0073\u0065\u006c\u0065\u0063\u0074\u0020\u0061\u006e\u0020\u0049\u006e\u0076\u006f\u0069\u0063\u0065\u0020\u0054\u0061\u0078\u0020\u0074\u006f\u0020\u0064\u0065\u006c\u0065\u0074\u0065'); return; } } function checkInvoiceType(frm){ if(frm.invoiceType.value == 1) { frm.shipperId.value = -1; frm.shipperId.disabled = true; frm.shipperIdText.value = ""; frm.shipperIdText.disabled = true; } else { frm.shipperIdText.disabled = false; frm.shipperId.disabled = false; } } function adjustment_amount_message ( fld, minVal, maxVal, DefaultValue, fldName){ var msg = MessageUtil.getMessage("\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0062\u0065\u0074\u0077\u0065\u0065\u006e\u0020\u0023\u0020\u0061\u006e\u0064\u0020\u0023", new Array(fldName, minVal, maxVal)); return validateAlert ( fld, DefaultValue, msg); }