/** * Validates and formats a time * * fld * the field that needs to be validated * isNullable * can the field be null * timeFmtFlag * flag to indicate the time format to validate * fieldName * a generic error message for the field, Other messages will be tacked on */ function isValidTime(timeField, isNullable, timeFmtField, fieldName) { var timeVal = trim(timeField); var timeFormat = parseNumInt(timeFmtField.value); var isValid = true; var errMsg = null; if(timeVal == ""){ if (!isNullable) { isValid = false; errMsg = MessageUtil.getMessage("\u0050\u006c\u0065\u0061\u0073\u0065\u0020\u0065\u006e\u0074\u0065\u0072\u0020\u0074\u0068\u0065\u0020\u0023\u002e", new Array(fieldName)); } else{ return true; } } if (isValid) { if (parseTime(timeField, timeFormat, fieldName) == null) { isValid = false; return isValid; } } if (!isValid) { if (errMsg == null) { if (timeFormat == 1) { errMsg = 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\u0023", new Array(fieldName, "HH:mm")); } else if (timeFormat == 2) { errMsg = 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\u0023", new Array(fieldName, "hh:mm")); } else { errMsg = MessageUtil.getMessage("\u0023\u0020\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0074\u0069\u006d\u0065\u0020\u0066\u006f\u0072\u006d\u0061\u0074\u0020\u0074\u006f\u0020\u0076\u0061\u006c\u0069\u0064\u0061\u0074\u0065\u002e\u0020\u0054\u0069\u006d\u0065\u0020\u0066\u006f\u0072\u006d\u0061\u0074\u0020\u0069\u0073\u003a\u0020\u0023", new Array(fieldName, timeFormat)); } } validateAlert(timeField, "", errMsg); } return isValid; } function parseTime(timeField, timeFormat, fieldName) { var parts; var hour = 0; var min = 0; var theTime = null; // parse out the hour/minute parts parts = parseParts(timeField.value, ":"); min = parseMinute(parts[1]); if (timeFormat == 1) { hour = parseHour24(parts[0]); } else if (timeFormat == 2) { hour = parseHour12(parts[0]); } else { return null; } if (hour < 0) { /*alert(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(fieldName)));*/ validateAlert(timeField, "", 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(fieldName))); return null; } else if (min < 0) { /*alert(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(fieldName)));*/ validateAlert(timeField, "", 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(fieldName))); return null; } // format the field to match the intended format timeField.value = formatHour(hour) + ":" + formatMinute(min); return timeField.value; } /** * Returns the hours for 24:00 hour format */ function parseHour24(hour) { var val = parseNumInt(hour); if (isNaN(val)) return -1; if (val < 0) return -1; if (val < 24) return val; return -1; } /** * Returns the hours for 12:00 hour format */ function parseHour12(hour) { var val = parseNumInt(hour); if (isNaN(val)) return -1; if (val <= 0) return -1; if (val <= 12) return val; return -1; } /** * Formats the year */ function formatHour(hour) { if (hour < 10) return "0" + hour.toString(); return hour.toString(); } /** * Returns the minutes */ function parseMinute(minute) { var val = parseNumInt(minute); if (isNaN(val)) return -1; if (val < 0) return -1; if (val < 60) return val; return -1; } /** * Formats the year */ function formatMinute(minute) { if (minute < 10) return "0" + minute.toString(); return minute.toString(); } /** * Validates and formats a date * * dateField * the field that needs to be validated * isNullable * can the field be null * dateFmtField * flag to indicate the date format to validate * fieldName * a generic error message for the field, Other messages will be tacked on */ function isValidDate(dateField, isNullable, dateFmtField, fieldName) { var dateVal = trim(dateField); var dateFormat = parseNumInt(dateFmtField.value); var isValid = true; var errMsg = null; if (dateVal == "") { if (!isNullable) { isValid = false; errMsg = MessageUtil.getMessage("\u0050\u006c\u0065\u0061\u0073\u0065\u0020\u0065\u006e\u0074\u0065\u0072\u0020\u0074\u0068\u0065\u0020\u0023\u002e", new Array(fieldName)); } else { return true; } } if (isValid) { if (parseDate(dateField, dateFormat, fieldName) == null) { isValid = false; } //Don't validate any futher if isValid is false if (isValid) { //This code checks to see if the date is equal or greater than "01-01-1970" var startDate = new Date("01-01-1970"); var dEarly = parseDate(dateField, dateFormat, fieldName); if (dEarly < startDate) { var msg = MessageUtil.getMessage("\u0054\u0068\u0065\u0020\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0065\u0071\u0075\u0061\u006c\u0020\u0074\u006f\u0020\u006f\u0072\u0020\u006c\u0061\u0074\u0065\u0072\u0020\u0074\u0068\u0061\u006e\u0020\u0031\u0073\u0074\u0020\u004a\u0061\u006e\u0020\u0031\u0039\u0037\u0030\u002e", new Array(fieldName)); return validateAlert(dateField, "", msg); } //This code checks to see if the date is equal or lesser than "01-19-2038" var endDate = new Date("01-19-2038"); if (dEarly > endDate) { var msg = MessageUtil.getMessage("\u0054\u0068\u0065\u0020\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0065\u0071\u0075\u0061\u006c\u0020\u0074\u006f\u0020\u006f\u0072\u0020\u006c\u0065\u0073\u0073\u0065\u0072\u0020\u0074\u0068\u0061\u006e\u0020\u0031\u0039\u0074\u0068\u0020\u004a\u0061\u006e\u0020\u0032\u0030\u0033\u0038\u002e", new Array(fieldName)); return validateAlert(dateField, "", msg); } } } if (!isValid) { if (errMsg == null) { if (dateFormat == 1) { errMsg = "\u0056\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065\u0020\u0066\u006f\u0072\u006d\u0061\u0074\u0020\u0069\u0073\u0020\u004d\u004d\u002d\u0064\u0064\u002d\u0079\u0079\u0079\u0079"; } else if (dateFormat == 2) { errMsg = "\u0056\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065\u0020\u0066\u006f\u0072\u006d\u0061\u0074\u0020\u0069\u0073\u0020\u004d\u004d\u004d\u002d\u0064\u0064\u002d\u0079\u0079\u0079\u0079"; } else if (dateFormat == 3) { errMsg = "\u0056\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065\u0020\u0066\u006f\u0072\u006d\u0061\u0074\u0020\u0069\u0073\u0020\u0064\u0064\u002d\u004d\u004d\u004d\u002d\u0079\u0079\u0079\u0079"; } else if (dateFormat == 4) { errMsg = "\u0056\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065\u0020\u0066\u006f\u0072\u006d\u0061\u0074\u0020\u0069\u0073\u0020\u0079\u0079\u0079\u0079\u002d\u004d\u004d\u002d\u0064\u0064"; } else if (dateFormat == 5) { errMsg = "\u0056\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065\u0020\u0066\u006f\u0072\u006d\u0061\u0074\u0020\u0069\u0073\u0020\u0079\u0079\u0079\u0079\u003f\u004d\u004d\u003f\u0064\u0064\u003f"; } else if (dateFormat == 6) { errMsg = "\u0056\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065\u0020\u0066\u006f\u0072\u006d\u0061\u0074\u0020\u0069\u0073\u0020\u0064\u0064\u002e\u004d\u004d\u002e\u0079\u0079\u0079\u0079"; } else { errMsg = MessageUtil.getMessage("\u0023\u0020\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065\u0020\u0066\u006f\u0072\u006d\u0061\u0074\u0020\u0074\u006f\u0020\u0076\u0061\u006c\u0069\u0064\u0061\u0074\u0065\u002e\u0020\u0044\u0061\u0074\u0065\u0020\u0066\u006f\u0072\u006d\u0061\u0074\u0020\u0069\u0073\u003a\u0020\u0023", new Array(fieldName, dateFormat)); } } return validateAlert(dateField, "", errMsg); } return true; } /** * Validates a date range. * It does not require isValidDate to have run prior * * startDateFld * The start date * startDateIsNullable * Can the startDate be blank * startDateFldName * the start dates name * endDateFld * the later date * endDateIsNullable * Can the endDate be blank * endDateFldName * the late dates name * dateFmtFlag * flag to indicate the date format to validate */ function isValidDateRangeFullComparisions(startDateFld, startDateIsNullable, startDateFldName, endDateFld, endDateIsNullable, endDateFldName, dateFmtFlag) { if (!isValidDate(startDateFld, startDateIsNullable, dateFmtFlag, startDateFldName)) return false; if (!isValidDate(endDateFld, endDateIsNullable, dateFmtFlag, endDateFldName)) return false; var startValue = trim(startDateFld); var endValue = trim(endDateFld); if ( startValue.length > 0 && endValue.length > 0) { if (!isValidDateRange(startDateFld,endDateFld,startDateFldName,endDateFldName,true, dateFmtFlag)) return false; } return true; } /** * This should be called After the "isValidDate" function * * startDateFld * The early date * endDateFld * the later date * startDateFldName * the early dates name * endDateFldName * the late dates name * isInclusive * true means the dates can be the same * dateFmtFlag * flag to indicate the date format to validate */ function isValidDateRange(startDateFld, endDateFld, startDateFldName, endDateFldName, isInclusive, dateFmtFlag) { var dEarly = parseDate(startDateFld, dateFmtFlag.value, startDateFldName); var dLate = parseDate(endDateFld, dateFmtFlag.value, endDateFldName); if (isInclusive) { 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\u0074\u0068\u0065\u0020\u0023", new Array(startDateFldName, endDateFldName)); return validateAlert(startDateFld, "", msg); } } else { 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\u0074\u0068\u0065\u0020\u0023", new Array(startDateFldName, endDateFldName)); return validateAlert(startDateFld, "", msg); } } return true; } /** * this should be called After the "isValidDate" function * This date checks to see if the date is equal or greater than today * * startDateFld * The early date * startDateFldName * the early dates name * dateFmtFlag * flag to indicate the date format to validate */ function isDateGreaterOrEqualtoToday(startDateFld, startDateFldName, dateFmtFlag) { var today = new Date(); var dEarly = parseDate(startDateFld, dateFmtFlag.value, startDateFldName); today = today - 24*60*60*1000; if (dEarly < today) { var msg = MessageUtil.getMessage("\u0054\u0068\u0065\u0020\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0065\u0071\u0075\u0061\u006c\u0020\u0074\u006f\u0020\u006f\u0072\u0020\u006c\u0061\u0074\u0065\u0072\u0020\u0074\u0068\u0061\u006e\u0020\u0074\u006f\u0064\u0061\u0079\u0073\u0020\u0064\u0061\u0074\u0065\u002e", new Array(startDateFldName)); return validateAlert(startDateFld, "", msg); } return true; } /** * added this method for PPOcreation RequiredDate field validation - Ashok * * this should be called After the "isValidDate" function * This date checks to see if the date is greater than today * * startDateFld * The early date * startDateFldName * the early dates name * dateFmtFlag * flag to indicate the date format to validate */ function isDateGreaterThanToday(startDateFld, startDateFldName, dateFmtFlag) { var today = new Date(); var dEarly = parseDate(startDateFld, dateFmtFlag.value, startDateFldName); if (dEarly <= today) { var msg = MessageUtil.getMessage("\u0054\u0068\u0065\u0020\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u006c\u0061\u0074\u0065\u0072\u0020\u0074\u0068\u0061\u006e\u0020\u0074\u006f\u0064\u0061\u0079\u0027\u0073\u0020\u0064\u0061\u0074\u0065\u002e", new Array(startDateFldName)); return validateAlert(startDateFld, "", msg); } return true; } /** * this should be called After the "isValidDate" function * This date checks to see if the date is equal or greater than today * * startDateFld * The early date * startDateFldName * the early dates name * dateFmtFlag * flag to indicate the date format to validate */ function isDateLessOrEqualtoToday(startDateFld, startDateFldName, dateFmtFlag) { var today = new Date(); var dEarly = parseDate(startDateFld, dateFmtFlag.value, startDateFldName); //today = today - 24*60*60*1000; if (dEarly > today) { var msg = MessageUtil.getMessage("\u0054\u0068\u0065\u0020\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0065\u0071\u0075\u0061\u006c\u0020\u0074\u006f\u0020\u006f\u0072\u0020\u006c\u0065\u0073\u0073\u0065\u0072\u0020\u0074\u0068\u0061\u006e\u0020\u0074\u006f\u0064\u0061\u0079\u0073\u0020\u0064\u0061\u0074\u0065\u002e", new Array(startDateFldName)); return validateAlert(startDateFld, "", msg); } return true; } /** * this should be called After the "isValidDate" function * This date checks to see if the date is equal or greater than today * * startDateFld * The early date * startDateFldName * the early dates name * dateFmtFlag * flag to indicate the date format to validate */ function isDateLessThanToday(startDateFld, startDateFldName, dateFmtFlag) { var today = new Date(); var dEarly = parseDate(startDateFld, dateFmtFlag.value, startDateFldName); //today = today - 24*60*60*1000; if (dEarly >= today) { var msg = MessageUtil.getMessage("\u0054\u0068\u0065\u0020\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u006c\u0065\u0073\u0073\u0020\u0074\u0068\u0061\u006e\u0020\u0074\u006f\u0064\u0061\u0079\u0027\u0073\u0020\u0064\u0061\u0074\u0065\u002e", new Array(startDateFldName)); return validateAlert(startDateFld, "", msg); } return true; } /** * this should be called After the "isValidDate" function * This date checks to see if the date is equal or greater than today * * startDateFld * The early date * startDateFldName * the early dates name * dateFmtFlag * flag to indicate the date format to validate */ function isDateLessOrEqualtoToday(startDateFld, startDateFldName, dateFmtFlag) { var today = new Date(); var dEarly = parseDate(startDateFld, dateFmtFlag.value, startDateFldName); //today = today - 24*60*60*1000; if (dEarly > today) { var msg = MessageUtil.getMessage("\u0054\u0068\u0065\u0020\u0023\u0020\u006d\u0075\u0073\u0074\u0020\u0062\u0065\u0020\u0065\u0071\u0075\u0061\u006c\u0020\u0074\u006f\u0020\u006f\u0072\u0020\u006c\u0065\u0073\u0073\u0065\u0072\u0020\u0074\u0068\u0061\u006e\u0020\u0074\u006f\u0064\u0061\u0079\u0073\u0020\u0064\u0061\u0074\u0065\u002e", new Array(startDateFldName)); return validateAlert(startDateFld, "", msg); } return true; } /** * Returns a javascript date, given the html field and format. */ function parseDate(dateField, dateFormat, fieldName) { var parts; var year = 0; var month = 0; var day = 0; var theDate = null; // parse out the month/day/year parts if (dateFormat == 1) { parts = parseParts(dateField.value, "/-"); if( parts.length < 3 ) return null; year = parseYear(parts[2]); month = parseMonth(parts[0]); day = parseDay(parts[1]); } else if (dateFormat == 2) { parts = parseParts(dateField.value, "/-"); if( parts.length < 3 ) return null; year = parseYear(parts[2]); month = parseMonthName(parts[0]); day = parseDay(parts[1]); } else if (dateFormat == 3) { parts = parseParts(dateField.value, "/-"); if( parts.length < 3 ) return null; year = parseYear(parts[2]); month = parseMonthName(parts[1]); day = parseDay(parts[0]); } else if (dateFormat == 4) { parts = parseParts(dateField.value, "/-"); if( parts.length < 3 ) return null; year = parseYear(parts[0]); month = parseMonth(parts[1]); day = parseDay(parts[2]); } else if (dateFormat == 5) { parts = parseParts(dateField.value, "/-\u5e74\u6708\u65e5"); if( parts.length < 3 ) return null; year = parseYear(parts[0]); month = parseMonth(parts[1]); day = parseDay(parts[2]); } else if (dateFormat == 6) { parts = parseParts(dateField.value, "."); if( parts.length < 3 ) return null; year = parseYear(parts[2]); month = parseMonth(parts[1]); day = parseDay(parts[0]); } else { return null; } if (day <= 0) { alert(MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065\u002e\u0020\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0079\u002e", new Array(fieldName))); return null; } else if (month <= 0) { alert(MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065\u002e\u0020\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006d\u006f\u006e\u0074\u0068\u002e", new Array(fieldName))); return null; } else if (year <= 0) { alert(MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065\u002e\u0020\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0079\u0065\u0061\u0072\u002e", new Array(fieldName))); return null; } theDate = new Date(year, month - 1, day); // validate that the parts are the same as entered if (day != theDate.getDate()) { alert(MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065\u002e\u0020\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0079\u002e", new Array(fieldName))); return null; } else if (month != theDate.getMonth() + 1) { alert(MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065\u002e\u0020\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006d\u006f\u006e\u0074\u0068\u002e", new Array(fieldName))); return null; } else if (year != theDate.getFullYear()) { alert(MessageUtil.getMessage("\u0023\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065\u002e\u0020\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0079\u0065\u0061\u0072\u002e", new Array(fieldName))); return null; } // format the field to match the intended format if (dateFormat == 1) { dateField.value = formatMonth(month) + "-" + formatDay(day) + "-" + formatYear(year); } else if (dateFormat == 2) { dateField.value = formatMonthName(month) + "-" + formatDay(day) + "-" + formatYear(year); } else if (dateFormat == 3) { dateField.value = formatDay(day) + "-" + formatMonthName(month) + "-" + formatYear(year); } else if (dateFormat == 4) { dateField.value = formatYear(year) + "-" + formatMonth(month) + "-" + formatDay(day); } else if (dateFormat == 5) { dateField.value = formatYear(year) + "\u5e74" + formatMonth(month) + "\u6708" + formatDay(day) + "\u65e5"; } else if (dateFormat == 6) { dateField.value = formatDay(day)+ "." + formatMonth(month) + "." + formatYear(year); } return theDate; } /** * Returns the full year */ function parseYear(year) { var yearVal = parseNumInt(year); if(!isNumeric(year)) return 0; if(year.length == 3) return 0; if (isNaN(year)) return 0; if (yearVal < 0) return 0; if (yearVal < 100) return 2000 + yearVal; if (yearVal <= 9999) return yearVal; return 0; } /** * Formats the year */ function formatYear(year) { if (year < 10) return "000" + year.toString(); if (year < 100) return "00" + year.toString(); if (year < 1000) return "0" + year.toString(); return year.toString(); } /** * Returns the month number for a month name */ function parseMonth(month) { var monthVal = parseNumInt(month); if(!isNumeric(month)) return 0; if (isNaN(month)) return 0; if (monthVal < 1 || monthVal > 12) return 0; return monthVal; } /** * Returns the month number for a month name */ function parseMonthName(month) { if (month.toUpperCase() == "JAN") return 1; if (month.toUpperCase() == "FEB") return 2; if (month.toUpperCase() == "MAR") return 3; if (month.toUpperCase() == "APR") return 4; if (month.toUpperCase() == "MAY") return 5; if (month.toUpperCase() == "JUN") return 6; if (month.toUpperCase() == "JUL") return 7; if (month.toUpperCase() == "AUG") return 8; if (month.toUpperCase() == "SEP") return 9; if (month.toUpperCase() == "OCT") return 10; if (month.toUpperCase() == "NOV") return 11; if (month.toUpperCase() == "DEC") return 12; //Check against the resource bundle var monthRB = ""; monthRB = "\u004a\u0061\u006e"; if(month == monthRB || month.toUpperCase() == monthRB.toUpperCase()){ return 1; } monthRB = "\u0046\u0065\u0062"; if(month == monthRB || month.toUpperCase() == monthRB.toUpperCase() ){ return 2; } monthRB = "\u004d\u0061\u0072"; if(month == monthRB || month.toUpperCase() == monthRB.toUpperCase()){ return 3; } monthRB = "\u0041\u0070\u0072"; if(month == monthRB || month.toUpperCase() == monthRB.toUpperCase()){ return 4; } monthRB = "\u004d\u0061\u0079"; if(month == monthRB || month.toUpperCase() == monthRB.toUpperCase()){ return 5; } monthRB = "\u004a\u0075\u006e"; if(month == monthRB || month.toUpperCase() == monthRB.toUpperCase()){ return 6; } monthRB = "\u004a\u0075\u006c"; if(month == monthRB || month.toUpperCase() == monthRB.toUpperCase()){ return 7; } monthRB = "\u0041\u0075\u0067"; if(month == monthRB || month.toUpperCase() == monthRB.toUpperCase()){ return 8; } monthRB = "\u0053\u0065\u0070"; if(month == monthRB || month.toUpperCase() == monthRB.toUpperCase()){ return 9; } monthRB = "\u004f\u0063\u0074"; if(month == monthRB || month.toUpperCase() == monthRB.toUpperCase()){ return 10; } monthRB = "\u004e\u006f\u0076"; if(month == monthRB || month.toUpperCase() == monthRB.toUpperCase()){ return 11; } monthRB = "\u0044\u0065\u0063"; if(month == monthRB || month.toUpperCase() == monthRB.toUpperCase()){ return 12; } return parseMonth(month); } /** * Formats the month */ function formatMonth(month) { if (month < 10) return "0" + month.toString(); return month.toString(); } /** * Returns the month name for a month number */ function formatMonthName(month) { switch (month) { case 1: return "JAN"; case 2: return "FEB"; case 3: return "MAR"; case 4: return "APR"; case 5: return "MAY"; case 6: return "JUN"; case 7: return "JUL"; case 8: return "AUG"; case 9: return "SEP"; case 10: return "OCT"; case 11: return "NOV"; case 12: return "DEC"; } return " "; } /** * Returns the day of the month */ function parseDay(day) { var dayVal = parseNumInt(day); if(!isNumeric(day)) return 0; if (isNaN(day)) return 0; if (dayVal < 0) return 0; if (dayVal <= 31) return dayVal; return 0; } /** * Formats the day */ function formatDay(day) { if (day < 10) return "0" + day.toString(); return day.toString(); } /** * Parses a string into individual parts, separated by delim */ function parseParts(data, delim) { var parts = new Array(); var pos = 0; var cnt = 0; for (var i = 0; i < data.length; i++) { if (delim.indexOf(data.substring(i, i + 1)) >= 0) { parts[cnt++] = data.substring(pos, i); pos = i + 1; } } if (pos >= data.length) { parts[cnt] = ""; } else { parts[cnt] = data.substring(pos); } return parts; } function parseNumInt(data) { if (typeof data != 'undefined') { while (data.charAt(0) == "0" && data.length > 1) { data = data.substring(1); } } return parseInt(data); } function isNumeric(data) { var i; for(i = 0; i < data.length; i++) { if(!(data.charAt(i) >= '0' && data.charAt(i) <= '9')) { return false; } } return true; }