what to do if application have 3 "ok" button with same
logical name and same properties, how qtp can identify them.

Answer Posted / shi

//**********************************************************
*************************************
//* Version information : 1.0


//*



//* Created Date : 04 Aug 2003



//* Author : Murali.TK


//* Modified on :
//* Modified By :

//*


//* Copyright notice :
//* Copyright (C) 2003 EmPower Works Limited. All rights
reserved.
//THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT
WARRANTY OF ANY KIND,
//EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF
//MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//**********************************************************
*************************************
//Variables
var varNull = ' ';
var arrNum = new Array
('0','1','2','3','4','5','6','7','8','9')
var varAlpha
= "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVxXyYzZ";
var varAlphaNum
= "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVxXyYzZ0123456
789";
var arrDays = new Array
('31','28','31','30','31','30','31','31','30','31','30','31'
);
var varBroken=0;
var varNumeric = "1234567890";
var strYearMsg = "is invalid";
var strIsNullMsg = " should not be NULL";
var strIsNumericMsg = " should be Numeric";
var strDateCompareMsg = " should be less than";
var strComboSelMsg = "Kindly select the ";
var strDateMsg = "should be Greater than or Equal to
Current Date";

//Added by Jeyaprakash on 12/09/2003
var strDateCheckMsg = " Less than or Equal to Current Date";

//CP 12 Sep 2003
var strDateValMsg="Timesheet Date should not be greater
than current server date";

var dtCh= "/"; //for isDate validation
var minYear=1900; //for isDate validation
var maxYear=2100; //for isDate validation

var MONTH_NAMES=new Array
('January','February','March','April','May','June','July','A
ugust','September','October','November','December','Jan','Fe
b','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','De
c');
var DAY_NAMES=new Array
('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday'
,'Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');


function getMonthDays(MonthNo)
{
return arrDays[MonthNo];
}




// ------------------------------------------------------
// Added by ANIL to check the Amount Field like "12.12" --
21-08-2003
function AmountValidation(idField)
{
var strTemp = idField.value;
varBroken=0;

re= /^([0-9]*|\d*\.\d{1}?\d*)$/ // This is the
Regular Expression
if (re.test(strTemp)) {
varBroken = 0;
return true;
}
else {
varBroken=1;
alert("Invalid Number");
idField.select();
return false;
}
}
//-----------------------------------------------------
function NumValidation(idField)
{
var strTemp = idField.value;
varBroken=0;
var varCharacter = 0;
// Added by ANIL if no value entered then dont
validate return true
if (strTemp.length<=0)
{
varBroken = 0;
return true;
}
else
{
for(var i=0;i<strTemp.length;i++)
{
if(varBroken==1) break;
for(var j=0;j<varAlpha.length;j++)
{
if(strTemp.charAt(i)
==varAlpha.charAt(j))
{
varCharacter =1;
varBroken = 1;
break;
}
}
}
if(varCharacter==1)
{
varBroken=1;
alert('Invalid Number!');
idField.select();
//idField.focus();
}
return false;
}
}
//------------------------------------------------------
function parseCurrency(x)
{
var strTotalAmount = new String(x);
var DecimalPlaces='';
var nonDecimalPlaces='';
var indexOfDot;
var TempDecimalPlaces='';
indexOfDot = strTotalAmount.indexOf('.')
if(indexOfDot>0)
{
for(var j=0;j<strTotalAmount.length;j++)
{
if(j<indexOfDot)

nonDecimalPlaces=nonDecimalPlaces+strTotalAmount.cha
rAt(j);
if(j>indexOfDot)

DecimalPlaces=DecimalPlaces+strTotalAmount.charAt
(j);
}
for(var j=0;j<DecimalPlaces.length;j++)
{
if(j==2)
{

TempDecimalPlaces=TempDecimalPlaces+".";
}

TempDecimalPlaces=TempDecimalPlaces+DecimalPlaces.ch
arAt(j);
}
return (nonDecimalPlaces+ "." + Math.round
(TempDecimalPlaces));
}
if(indexOfDot=='-1')
{
return (x+".00");
}
}
//----------------------------------------------------------
------------
function CurrFieldOnKeyPress(id)
{
var blnNumber='0'; //if value = 0 then false, value=1 then
true
var typedChar =String.fromCharCode(event.keyCode);
var ArrNum = new Array
('0','1','2','3','4','5','6','7','8','9','.');
for(var i=0;i<ArrNum.length;i++)
{
if(typedChar==ArrNum[i])
{
blnNumber='1';
if(id.value.indexOf('.')!=-1)
{
var DotAt=parseInt(id.value.indexOf
('.'));
if(id.value.charAt(DotAt+2)!
=''&&id.value!='0.00')
{
event.keyCode=0;
}
}
}

}
if(blnNumber=='0') event.keyCode=0;
}
//----------------------------------------------------------
---------------
function HourValidation(id)
{
var blnNumber='0'; //if value = 0 then false,
value=1 then true
var typedChar =String.fromCharCode(event.keyCode);
var ArrNum = new Array
('0','1','2','3','4','5','6','7','8','9');
for(var i=0;i<ArrNum.length;i++)
{
if(typedChar==ArrNum[i])
{
blnNumber='1';
var totHours = id.value+typedChar;
if(parseInt(totHours)>23)
{
event.keyCode=0;
break;
}
}
}
if(blnNumber=='0') event.keyCode=0;
}
//----------------------------------------------------------
-------------
function minValidation(id)
{
var blnNumber='0'; //if value = 0 then false,
value=1 then true
var typedChar =String.fromCharCode(event.keyCode);
var ArrNum = new Array
('0','1','2','3','4','5','6','7','8','9');
for(var i=0;i<ArrNum.length;i++)
{
if(typedChar==ArrNum[i])
{
blnNumber='1';
var totHours = id.value+typedChar;
if(parseInt(totHours)>59)
{
event.keyCode=0;
break;
}
}
}
if(blnNumber=='0') event.keyCode=0;
}
//----------------------------------------------------------
------------
function TimeFieldOnBlur(id)
{
if(id.value.length==1)
{
id.value='0'+id.value;
}
if(id.value.length==0)
{
id.value='00';
}

}
//----------------------------------------------------------
-----------
function CCur(id)
{
if(id.value.indexOf('.')<0)
{
if(id.value=='') id.value=id.value+'0.00';
else
id.value=id.value+'.00';
}
var DotAt=parseInt(id.value.indexOf('.'));
if(id.value.charAt(DotAt+2)=='')
{
id.value=id.value+'0';
}
if(DotAt==0)
id.value='0'+id.value;
}

//-----------------------------------------------------
// Added by ANIL - onkey press which allow numbers and
period(.) -- 22-08-2003
function AmountOnly_onkeypress(p){
if (window.event.keyCode!=46) {
if(window.event.keyCode<48 ||
window.event.keyCode>57){
window.event.keyCode=false
return false
}
}
}
//-----------------------------------------------------
// Added by ANIL - onkey press which allow only numbers --
22-08-2003
function NumberOnly_onkeypress(p){
if(window.event.keyCode<48 ||
window.event.keyCode>57){
window.event.keyCode=false
return false
}
}

//-----------------------------------------------------
// Added by ANIL - onkey press which allow all characters
except special char(periods(.) and slash (/)
// are allowed ) -- 28-08-2003
function URLOnly_onkeypress(p)
{
if(window.event.keyCode<45 ||
window.event.keyCode>58)
{
if(window.event.keyCode<65 ||
window.event.keyCode>90)
{
if(window.event.keyCode<97 ||
window.event.keyCode>122)
{
window.event.keyCode=false
return false
}
}
}
}

//-----------------------------------------------------
// Added by ANIL - onkey press which allow only Alphabets
// are allowed ) -- 28-08-2003

//Changed by Jeyaprakash on 7/4/2003
function AlphabetOnly_onkeypress(p)
{
if (window.event.keyCode != 32)
{
if(window.event.keyCode<65 ||
window.event.keyCode>90)
{
if(window.event.keyCode<97 ||
window.event.keyCode>122)
{
window.event.keyCode=false
return false
}
}
}
}


//-----------------------------------------------------
// Added by ANIL - onkey press which allow only number
and "()" and "-"
// are allowed ) -- 28-08-2003
function PhoneOnly_onkeypress(p)
{
if ( window.event.keyCode != 40)
{
if (window.event.keyCode != 41)
{
if (window.event.keyCode != 45)
{
if (window.event.keyCode != 44)
{
if(window.event.keyCode<48
|| window.event.keyCode>57){

window.event.keyCode=false
return false
}
}
}
}
}
}


//-----------------------------------------------------
// Added by Vijayalakshmi - onkey press it allows all
characters and numbers except special characters like period
(.) and slash (/)
function alphanumericOnly_onkeypress(p)
{
if (window.event.keyCode != 32)
{
if(window.event.keyCode<48 ||
window.event.keyCode>57 )
{
if(window.event.keyCode<65 ||
window.event.keyCode>90)
{
if(window.event.keyCode<97
|| window.event.keyCode>122)
{

window.event.keyCode=false
return false
}
}
}
}
}



//----------------------------------------------------------
---------
function DaysValidation(idDField,idMField,idYField)
{
var strTemp = idDField.value;
if(parseInt(strTemp)>parseInt(arrDays
[idMField.value-1]))
{
if(idMField.value==2 && (parseInt
(idYField.value)%4==0)&& parseInt(strTemp)<parseInt('30'))
{
}
else
{
alert('Invalid Date for the
selected Month!');
varBroken=1;
idDField.select();
}
}
return false;
}

//----------------------------------------------------------
-------------
// Function Added by ANIL - 21/08/2003

//Changed by Jeyaprakash - To check valid year
//--commented by heamraj - The same name has been used
commonlibrary.js
/*


function checkDate(day, month, year)
{
var err=0
if (month<1 || month>12) err = 1
if (day<1 || day>31) err = 1
if (day==31 && (month==4 || month==6 || month==9 ||
month==11)) err=1
if (year.length < 4) err =1

if (month==2)
{
if ((year%4==0) && (year%100!=0 || year%
400==0))
{
if (day>29) err=1
}
else
{
if (day>28) err=1
}
}
//if (day == "" || month == "" || year == "") err=1
//Added to Check Valid Year - Jeyaprakash
if (!(year > 1900 && year <= 2050))
err=1;


if (err==1)
{
return false
}
else
{
return true
}
}

*/

//Checking for year validation
function ValidateYear(mYear,mMsg)
{
var mYearValue = mYear.value;

if(mYearValue =='' || mYearValue =='0000' ||
mYearValue.length <4)
{
alert(mMsg + strYearMsg);
mYear.select();
return false;
}
//Checking for Numeric value for Year
for(var i=0;i<mYearValue.length;i++)
{
if(varNumeric.indexOf(mYearValue.charAt(i))
<0)
{
alert(strYearMsg);
mYear.select();
return false;
}
}
return true;
}

function CheckEmail(mField)
{
varBroken=0;
mVal = mField;
if(mVal.value=="")
{
///*alert("Kindly enter e-mail address.")
//mVal.focus()
varBroken=0
}
else
{
mail=mVal.value
at_pos=mail.indexOf("@")
dot_pos=mail.indexOf(".")
if(at_pos<1 || dot_pos<1)
{
alert("Kindly check position of '@'
and '.' in email address.")
mVal.focus()
varBroken=1
}
else
{
mail=mVal.value
condition="yes"
var at_count=0
var dot_count=0
var temp=0
for(var i=0;i<mail.length;i++)
{
if((mail.charCodeAt(i)>0 &&
mail.charCodeAt(i)<48)||(mail.charCodeAt(i)>57 &&
mail.charCodeAt(i)<65)||(mail.charCodeAt(i)>91 &&
mail.charCodeAt(i)<97)||mail.charCodeAt(i)>122)
{
if(mail.charAt(i)
=="@"||mail.charAt(i)==".")
{
if
(mail.charAt(i)=="@"){at_count++}else{dot_count++} //
counts the no. of times @ and . appears in email
if
(dot_count>=1)
{

dot_pos=i

if((dot_pos>at_pos) && temp==0)

{

pos=dot_pos-at_pos

temp++

}

}
}
else
{

condition="no"

i=mail.length
}
}
}
if(condition=="no")
{
alert("Your email contains
a blank space or special character.")
varBroken.focus()
varBroken=1
}
else
{
if(at_count>1)
{
alert("E-mail
contains extra @ ")
mVal.focus()
varBroken=1
}
else
{
if(pos<2)
{
alert
("Missing domain name between '@' and '.'")
mVal.focus()
varBroken=1

i=mail.length
}
else
{

count=dot_pos+1
domain=""
for
(count;count<mail.length;count++)
{

domain=domain+mail.charAt(count)
}
dom=new
Array
("au","com","net","org","edu","in","mil","gov","arpa","biz",
"aero","name","coop","info","pro","museum")
error="yes"
for(var
k=0;k<dom.length;k++)
{
if
(domain.toLowerCase()==dom[k])
{

k=dom.length

error="no"
}
}
if
((error=="yes" && (domain.length>2)) || (domain.length<2))
{

alert("Domain name must end with well known domains
\n or 2-lettered country name. eg com,edu,in etc.")

mVal.focus()

varBroken=1
}

}
}
}
}
}
//return varBroken
}
//Trim function by Jeyaprakash
function trim(s) {
while (s.substring(0,1) == ' ') {
s = s.substring(1,s.length);
}
while (s.substring(s.length-1,s.length) == ' ') {
s = s.substring(0,s.length-1);
}
return s;
}

// Checking for ISNull
function IsNullValue(mFieldObj, mMsg)
{
var mFieldValue = trim(mFieldObj.value);
if(mFieldValue.length<=0)
{
alert(mMsg + strIsNullMsg);
mFieldObj.select();
return false;
}
return true;
}

function IsNumeric(mFieldObj, mMsg)
{
var mFieldValue = mFieldObj.value;
//Checking for Numeric value
for(var i=0;i<mFieldValue.length;i++)
{
if(varNumeric.indexOf(mFieldValue.charAt(i))
<0)
{
alert(mMsg + strIsNumericMsg);
mFieldObj.select();
return false;
}
}
return true;
}

/*
function isSelectDateGreater(mDate,mMonth,mYear,mMsg)
{
var mMonFound=true;
var mYearFound=true;
var mFound=false;
var mFirstDate=new Date();
var mSecondDate=new Date(mMonth+mDate+", "+mYear);

//alert("Selected Year "+mSecondDate.getFullYear()
+ "---- Current Year" + mFirstDate.getFullYear());

if(mSecondDate.getFullYear() <
mFirstDate.getFullYear())
{
alert('Selected Year is lesser than Current
Year');
mYearFound = false;
}

///alert("Selected Month "+(mSecondDate.getMonth()
+1) + "---- Current Month "+(mFirstDate.getMonth()+1));


if(mSecondDate.getMonth()+1 < mFirstDate.getMonth()
+1)
{
alert('Selected Month is lesser than
Current Month');
mMonFound = false;
}

//alert("Selected Date is "+(mSecondDate.getDate
()) + "---- Current Date is "+(mFirstDate.getDate()) );


if(mSecondDate.getDate() < mFirstDate.getDate() ||
mYearFound ==false || mMonFound ==false)
{
alert('Selected Date is lesser than Current
Date');
mFound = true;
}

if(mFound)
{
alert(mMsg+strDateMsg);
return false;
}
else
return false;
}*/


function CheckComboSelection(comboCtrl,mMsg1)
{
if(comboCtrl.options.selectedIndex<=0)
{
alert(strComboSelMsg + mMsg1);
return false;
}
else
return true;
}


function CompareTwoDates(FromDay, FromMonth, FromYear,
ToDay, ToMonth, ToYear, mMsg)
{

var mFirstDate=new Date
(FromDay+FromMonth+", "+FromYear);
var mSecondDate=new Date(ToDay+ToMonth+", "+ToYear);

var mToCheck=true;
var permanentFalse=true;

if(mSecondDate.getFullYear()==
mFirstDate.getFullYear())
{
mToCheck=false; // check
}
else if(mSecondDate.getFullYear() <
mFirstDate.getFullYear())
{
permanentFalse=false; //out
}
else if(mSecondDate.getMonth()+1 >
mFirstDate.getMonth()+1)
{
permanentFalse=true; // ok
mToCheck==true; // ok
}

if(mToCheck==false)
{

if(mSecondDate.getFullYear()
==mFirstDate.getFullYear())
{
if(mSecondDate.getMonth()+1 ==
mFirstDate.getMonth()+1)
{
mToCheck=false; //check

//permanentFalse=false; //out
}
else if(mSecondDate.getMonth()+1 <
mFirstDate.getMonth()+1)
{
permanentFalse=false; //out
}
else if(mSecondDate.getMonth()+1 >
mFirstDate.getMonth()+1)
{
permanentFalse=true; //ok
mToCheck==true; // ok
}
}

}
if(permanentFalse==true && mToCheck==false)
{
if(mSecondDate.getMonth()+1 ==
mFirstDate.getMonth()+1)
{
if(mSecondDate.getDate() <
mFirstDate.getDate())
{
permanentFalse=false; // out
}
}
}

if(permanentFalse==false )
{
alert(mMsg);
return false;
}
else
return true;
}



// If the date1 is less than date2 -- Added by murugavel
//Modified for
mDate,mDateFormat,mDateNext,mDateNextFormat - >
date1,dateformat1,date2,dateformat2
//function compareDatesWithFormatsLess
(mDate,mDateFormat,mDateNext,mDateNextFormat)
function compareDatesWithFormatsLess
(date1,dateformat1,date2,dateformat2)
{
var d1=getDateFromFormat(date1,dateformat1);
var d2=getDateFromFormat(date2,dateformat2);

if (d1==0 || d2==0)
{
return -1;
}
else if (d1 < d2)
{
return 2;
}
return 0;
}
// compareDatesWithFormatsLess - end



function CheckFieldCount(mObj, mMaxCount ,mMsg)
{
var mValue = mObj.value;
if(mValue.length > mMaxCount)
{
alert(mMsg+' Cannot Exceed Maximum length
of ' + mMaxCount);
//Changed By Jeyaprakash - To set focus on
the Field
mObj.focus();
//mObj.value = mValue.substr(0, mMaxCount);
return false;
}
else
return true;
}

function isInteger(s){
var i;
for (i = 0; i < s.length; i++){
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}

function stripCharsInBag(s, bag){
var i;
var returnString = "";
// Search through string's characters one by one.
// If character is not in bag, append to returnString.
for (i = 0; i < s.length; i++){
var c = s.charAt(i);
if (bag.indexOf(c) == -1) returnString += c;
}
return returnString;
}

function daysInFebruary (year){
// February has 29 days in any year evenly
divisible by four,
// EXCEPT for centurial years which are not also
divisible by 400.
return (((year % 4 == 0) && ( (!(year % 100 == 0)) ||
(year % 400 == 0))) ? 29 : 28 );
}

function DaysArray(n) {
for (var i = 1; i <= n; i++) {
this[i] = 31
if (i==4 || i==6 || i==9 || i==11) {this[i]
= 30}
if (i==2) {this[i] = 29}
}
return this
}

// Date format should be -- mm/dd/yyyy for this function
function isDate(dtStr, mMsg)
{
var daysInMonth = DaysArray(12)
var pos1=dtStr.indexOf(dtCh)
var pos2=dtStr.indexOf(dtCh,pos1+1)
var strMonth=dtStr.substring(0,pos1)
var strDay=dtStr.substring(pos1+1,pos2)
var strYear=dtStr.substring(pos2+1)
strYr=strYear
if (strDay.charAt(0)=="0" && strDay.length>1)
strDay=strDay.substring(1)
if (strMonth.charAt(0)=="0" && strMonth.length>1)
strMonth=strMonth.substring(1)
for (var i = 1; i <= 3; i++) {
if (strYr.charAt(0)=="0" && strYr.length>1)
strYr=strYr.substring(1)
}
month=parseInt(strMonth)
day=parseInt(strDay)
year=parseInt(strYr)
if (pos1==-1 || pos2==-1){
alert("The date format should be :
mm/dd/yyyy")
return false
}
if (strMonth.length<1 || month<1 || month>12){
alert("Kindly enter a valid month")
return false
}
if (strDay.length<1 || day<1 || day>31 || (month==2
&& day>daysInFebruary(year)) || day > daysInMonth[month]){
alert("Kindly enter a valid day")
return false
}
if (strYear.length != 4 || year==0 || year<minYear
|| year>maxYear){
alert("Kindly enter a valid 4 digit year
between "+minYear+" and "+maxYear)
return false
}
if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger
(stripCharsInBag(dtStr, dtCh))==false){
alert("Kindly enter a valid date for " +
mMsg)
return false
}
return true
}

// ---------------------------------------------------------
----------
// compareDates(date1,date1format,date2,date2format)
// Compare two date strings to see which is greater.
// Returns:
// 1 if date1 is greater than date2
// 0 if date2 is greater than date1 of if they are the
same
// -1 if either of the dates is in an invalid format
// ---------------------------------------------------------
----------
// Field | Full Form | Short Form
// -------------+--------------------+----------------------
-
// Year | yyyy (4 digits) | yy (2 digits), y (2
or 4 digits)
// Month | MMM (name or abbr.)| MM (2 digits), M (1
or 2 digits)
// | NNN (abbr.) |
// Day of Month | dd (2 digits) | d (1 or 2 digits)
// Day of Week | EE (name) | E (abbr)
// Hour (1-12) | hh (2 digits) | h (1 or 2 digits)
// Hour (0-23) | HH (2 digits) | H (1 or 2 digits)
// Hour (0-11) | KK (2 digits) | K (1 or 2 digits)
// Hour (1-24) | kk (2 digits) | k (1 or 2 digits)
// Minute | mm (2 digits) | m (1 or 2 digits)
// Second | ss (2 digits) | s (1 or 2 digits)
// AM/PM | a |

function compareDatesWithFormats
(date1,dateformat1,date2,dateformat2)
{
var d1=getDateFromFormat(date1,dateformat1);
var d2=getDateFromFormat(date2,dateformat2);
if (d1==0 || d2==0)
{
return -1;
}
else if (d1 > d2)
{
return 1;
}
return 0;
}


// ---------------------------------------------------------
---------
// getDateFromFormat( date_string , format_string )
//
// This function takes a date string and a format string.
It matches
// If the date string matches the format string, it returns
the
// getTime() of the date. If it does not match, it returns
0.
// ---------------------------------------------------------
---------
function getDateFromFormat(val,format) {
val=val+"";
format=format+"";
var i_val=0;
var i_format=0;
var c="";
var token="";
var token2="";
var x,y;
var now=new Date();
var year=now.getYear();
var month=now.getMonth()+1;
var date=1;
var hh=now.getHours();
var mm=now.getMinutes();
var ss=now.getSeconds();
var ampm="";

while (i_format < format.length) {
// Get next token from format string
c=format.charAt(i_format);
token="";
while ((format.charAt(i_format)==c) &&
(i_format < format.length)) {
token += format.charAt(i_format++);
}
// Extract contents of value based on
format token
if (token=="yyyy" || token=="yy" ||
token=="y") {
if (token=="yyyy") { x=4;y=4; }
if (token=="yy") { x=2;y=2; }
if (token=="y") { x=2;y=4; }
year=_getInt(val,i_val,x,y);
if (year==null) { return 0; }
i_val += year.length;
if (year.length==2) {
if (year > 70) { year=1900+
(year-0); }
else { year=2000+(year-0); }
}
}
else if (token=="MMM"||token=="NNN"){
month=0;
for (var i=0; i<MONTH_NAMES.length;
i++) {
var month_name=MONTH_NAMES
[i];
if (val.substring
(i_val,i_val+month_name.length).toLowerCase()
==month_name.toLowerCase()) {
if (token=="MMM"||
(token=="NNN"&&i>11)) {
month=i+1;
if
(month>12) { month -= 12; }
i_val +=
month_name.length;
break;
}
}
}
if ((month < 1)||(month>12)){return
0;}
}
else if (token=="EE"||token=="E"){
for (var i=0; i<DAY_NAMES.length;
i++) {
var day_name=DAY_NAMES[i];
if (val.substring
(i_val,i_val+day_name.length).toLowerCase()
==day_name.toLowerCase()) {
i_val +=
day_name.length;
break;
}
}
}
else if (token=="MM"||token=="M") {
month=_getInt
(val,i_val,token.length,2);
if(month==null||(month<1)||
(month>12)){return 0;}
i_val+=month.length;}
else if (token=="dd"||token=="d") {
date=_getInt
(val,i_val,token.length,2);
if(date==null||(date<1)||(date>31))
{return 0;}
i_val+=date.length;}
else if (token=="hh"||token=="h") {
hh=_getInt
(val,i_val,token.length,2);
if(hh==null||(hh<1)||(hh>12))
{return 0;}
i_val+=hh.length;}
else if (token=="HH"||token=="H") {
hh=_getInt
(val,i_val,token.length,2);
if(hh==null||(hh<0)||(hh>23))
{return 0;}
i_val+=hh.length;}
else if (token=="KK"||token=="K") {
hh=_getInt
(val,i_val,token.length,2);
if(hh==null||(hh<0)||(hh>11))
{return 0;}
i_val+=hh.length;}
else if (token=="kk"||token=="k") {
hh=_getInt
(val,i_val,token.length,2);
if(hh==null||(hh<1)||(hh>24))
{return 0;}
i_val+=hh.length;hh--;}
else if (token=="mm"||token=="m") {
mm=_getInt
(val,i_val,token.length,2);
if(mm==null||(mm<0)||(mm>59))
{return 0;}
i_val+=mm.length;}
else if (token=="ss"||token=="s") {
ss=_getInt
(val,i_val,token.length,2);
if(ss==null||(ss<0)||(ss>59))
{return 0;}
i_val+=ss.length;}
else if (token=="a") {
if (val.substring
(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}
else if (val.substring
(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}
else {return 0;}
i_val+=2;}
else {
if (val.substring
(i_val,i_val+token.length)!=token) {return 0;}
else {i_val+=token.length;}
}
}
// If there are any trailing characters left in the
value, it doesn't match
if (i_val != val.length) { return 0; }
// Is date valid for month?
if (month==2) {
// Check for leap year
if ( ( (year%4==0)&&(year%100 != 0) ) ||
(year%400==0) ) { // leap year
if (date > 29){ return 0; }
}
else { if (date > 28) { return 0; } }
}
if ((month==4)||(month==6)||(month==9)||
(month==11)) {
if (date > 30) { return 0; }
}
// Correct hours value
if (hh<12 && ampm=="PM") { hh=hh-0+12; }
else if (hh>11 && ampm=="AM") { hh-=12; }
var newdate=new Date(year,month-1,date,hh,mm,ss);
return newdate.getTime();
}

// ---------------------------------------------------------
---------
// Utility functions for parsing in getDateFromFormat()
// ---------------------------------------------------------
---------

//function LZ(x) {return(x&lt;0||x&gt;9?"":"0")+x}
function _isInteger(val) {
var digits="1234567890";
for (var i=0; i < val.length; i++) {
if (digits.indexOf(val.charAt(i))==-1) {
return false; }
}
return true;
}
function _getInt(str,i,minlength,maxlength) {
for (var x=maxlength; x>=minlength; x--) {
var token=str.substring(i,i+x);
if (token.length < minlength) { return
null; }
if (_isInteger(token)) { return token; }
}
return null;
}

// ---------------------------------------------------------
---------
// isDate ( date_string, format_string )
// Returns true if date string matches format of format
string and
// is a valid date. Else returns false.
// It is recommended that you trim whitespace around the
value before
// passing it to this function, as whitespace is NOT
ignored!
// ---------------------------------------------------------
---------
function isDateWithFormat(val,format) {
var date=getDateFromFormat(val,format);
if (date==0) { return false; }
return true;
}
// ---------------------------------------------------------
------------------------




//Added By Jeyaprakash on 12/09/2003
//Alerts if the Given date is Greater than Current Date

function CompareDate(FromDay, FromMonth, FromYear, mMsg)
{

var mFirstDate=new Date();//Current Date
var mSecondDate=new Date
(FromDay+FromMonth+", "+FromYear);
var mToCheck=true;
var permanentFalse=true;

if( mFirstDate.getFullYear()==
mSecondDate.getFullYear())
{
mToCheck=false; // check
}
else if(mFirstDate.getFullYear() <
mSecondDate.getFullYear() )
{
permanentFalse=false; //out
}
else if(mFirstDate.getMonth()+1 >
mSecondDate.getMonth()+1 )
{
permanentFalse=true; // ok
mToCheck==true; // ok
}

if(mToCheck==false)
{

if(mFirstDate.getFullYear()
==mSecondDate.getFullYear() )
{
if(mFirstDate.getMonth()+1 ==
mSecondDate.getMonth()+1 )
{
mToCheck=false; //check

//permanentFalse=false; //out
}
else if(mFirstDate.getMonth()+1 <
mSecondDate.getMonth()+1 )
{
permanentFalse=false; //out
}
else if(mFirstDate.getMonth()+1 >
mSecondDate.getMonth()+1 )
{
permanentFalse=true; //ok
mToCheck==true; // ok
}
}

}
if(permanentFalse==true && mToCheck==false)
{
if( mFirstDate.getMonth()+1 ==
mSecondDate.getMonth()+1 )
{

if(mFirstDate.getDate() <
mSecondDate.getDate() )
{
permanentFalse=false; // out
}
}
}
if(permanentFalse==false )
{
alert(mMsg + strDateCheckMsg);
return false;
}
else
return true;
}
/*
Begin 12 Sep 2003 CP
Timesheet date should not be greater than server date
*/

function CompareWithServerDate
(currDay,currMon,currYear,TSDay, TSMon, TSYear)
{
//alert(currDate);
//var mFirstDate=new Date();//Current Date
currDay=parseInt(currDay);
currMon=parseInt(currMon);
currYear=parseInt(currYear);

TSDay=parseInt(TSDay);

TSMon=parseInt(TSMon);

TSYear=parseInt(TSYear);


var mTSDate=new Date(TSDay+TSMon+", "+TSYear);
var mToCheck=true;
var permanentFalse=true;
if(currYear == TSYear)
{
mToCheck=false; // check
}
else if(currYear < TSYear )
{
permanentFalse=false; //out
}
else if(currMon+1 > TSMon+1 )
{
permanentFalse=true; // ok
mToCheck==true; // ok
}

if(mToCheck==false)
{

if(currYear==TSYear )
{
if(currMon+1 == TSMon+1 )
{
mToCheck=false; //check

//permanentFalse=false; //out
}
else if(currMon+1 < TSMon+1 )
{
permanentFalse=false; //out
}
else if(currMon+1 > TSMon+1 )
{
permanentFalse=true; //ok
mToCheck==true; // ok
}
}

}
if(permanentFalse==true && mToCheck==false)
{
if( currMon+1 == TSMon+1 )
{

if(TSDay > currDay)
{
permanentFalse=false; // out
}
}
}
if(permanentFalse==false )
{
alert(strDateValMsg);
return false;
}
else
return true;
}


//End 12 Sep 2003 CP
//Calendar Dates
function CalendarCompareTwoDates(FirstDate,SecDate)
{

var mFirstDate=new Date(FirstDate.substring(3,6)
+FirstDate.substring(0,2)+", "+FirstDate.substring(7,11));
var mSecondDate=new Date(SecDate.substring(3,6)
+SecDate.substring(0,2)+", "+SecDate.substring(7,11));
//var mFirstDate=new Date
(FromDay+FromMonth+", "+FromYear);
//var mSecondDate=new Date
(ToDay+ToMonth+", "+ToYear);

var mToCheck=true;
var permanentFalse=true;

if(mSecondDate.getFullYear()==
mFirstDate.getFullYear())
{
mToCheck=false; // check
}
else if(mSecondDate.getFullYear() <
mFirstDate.getFullYear())
{
permanentFalse=false; //out
}
else if(mSecondDate.getMonth()+1 >
mFirstDate.getMonth()+1)
{
permanentFalse=true; // ok
mToCheck==true; // ok
}

if(mToCheck==false)
{

if(mSecondDate.getFullYear()
==mFirstDate.getFullYear())
{
if(mSecondDate.getMonth()+1 ==
mFirstDate.getMonth()+1)
{
mToCheck=false; //check

//permanentFalse=false; //out
}
else if(mSecondDate.getMonth()+1 <
mFirstDate.getMonth()+1)
{
permanentFalse=false; //out
}
else if(mSecondDate.getMonth()+1 >
mFirstDate.getMonth()+1)
{
permanentFalse=true; //ok
mToCheck==true; // ok
}
}

}
if(permanentFalse==true && mToCheck==false)
{
if(mSecondDate.getMonth()+1 ==
mFirstDate.getMonth()+1)
{
if(mSecondDate.getDate() <
mFirstDate.getDate())
{
permanentFalse=false; // out
}
}
}

if(permanentFalse==false )
{
//alert(mMsg);
return false;
}
else
return true;
}


//----------------------------------------------------------
------------
function NullValidation(idField,FieldName)
{
var strTemp=idField.value;
varBroken=0;
var varSpace = 0;
varOk= 0;
for(var i=0;i<strTemp.length;i++)
{
if(varOk==1) break;
for(var j=0;j<varNull.length;j++)
{
if(strTemp.charAt(i)!=varNull.charAt
(j))
{
varOk=1;
}
else
{
varSpace++;
}
}
}
if(varOk==0)
{
varBroken=1;
alert('Kindly enter the ' +FieldName ); // \n
Invalid Entry!');
idField.focus();
}
else
{
varBroken=0;
}

}

//Added By Jeyaprakash
function NullValidationWithOutFocus(idField,FieldName)
{
var strTemp=idField.value;
varBroken=0;
var varSpace = 0;
varOk= 0;
for(var i=0;i<strTemp.length;i++)
{
if(varOk==1) break;
for(var j=0;j<varNull.length;j++)
{
if(strTemp.charAt(i)!=varNull.charAt
(j))
{
varOk=1;
}
else
{
varSpace++;
}
}
}
if(varOk==0)
{
varBroken=1;
alert('Kindly enter the ' +FieldName );
}
else
{
varBroken=0;
}

}



//-----------------------------------------------------
function NumValidation(idField)
{

var strTemp = idField.value;

varBroken=0;
var varCharacter = 0;
// Added by ANIL if no value entered then dont
validate return true
if (strTemp.length<=0)
{
varBroken = 0;
return true;
}
else
{
for(var i=0;i<strTemp.length;i++)
{
if(varBroken==1) break;
for(var j=0;j<varAlpha.length;j++)
{
if(strTemp.charAt(i)
==varAlpha.charAt(j))
{
varCharacter =1;
varBroken = 1;
break;
}
}
}
if(varCharacter==1)
{
varBroken=1;
alert('Kindly enter a Valid
Number');
idField.select();
//idField.focus();
}
return false;
}
}
//Added By Jeyaprakash on 13/09/2003
//Alerts if the Given date is Greater than Current Server
Date

function CompareServerDate
(currDay,currMon,currYear,TSDay,TSMonth,TSYear,mMsg)
{
var mFirstDate=new Date
(currDay+currMon+", "+currYear);//Current Date
var mSecondDate=new Date(TSDay+TSMonth+", "+TSYear);
var mToCheck=true;
var permanentFalse=true;

if( mFirstDate.getFullYear()==
mSecondDate.getFullYear())
{
mToCheck=false; // check
}
else if(mFirstDate.getFullYear() <
mSecondDate.getFullYear() )
{
permanentFalse=false; //out
}
else if(mFirstDate.getMonth()+1 >
mSecondDate.getMonth()+1 )
{
permanentFalse=true; // ok
mToCheck==true; // ok
}

if(mToCheck==false)
{

if(mFirstDate.getFullYear()
==mSecondDate.getFullYear() )
{
if(mFirstDate.getMonth()+1 ==
mSecondDate.getMonth()+1 )
{
mToCheck=false; //check

//permanentFalse=false; //out
}
else if(mFirstDate.getMonth()+1 <
mSecondDate.getMonth()+1 )
{
permanentFalse=false; //out
}
else if(mFirstDate.getMonth()+1 >
mSecondDate.getMonth()+1 )
{
permanentFalse=true; //ok
mToCheck==true; // ok
}
}

}
if(permanentFalse==true && mToCheck==false)
{
if( mFirstDate.getMonth()+1 ==
mSecondDate.getMonth()+1 )
{

if(mFirstDate.getDate() <
mSecondDate.getDate() )
{
permanentFalse=false; // out
}
}
}
if(permanentFalse==false )
{
alert("Kindly enter "+mMsg +
strDateCheckMsg);
return false;
}
else
return true;
}


////////////////////////////////////////////////////////////
/////////////////

//Checking for year validation
function ValidateYear(mYear,mMsg)
{
var mYearValue = mYear.value;

if(mYearValue =='' || mYearValue =='0000' ||
mYearValue.length <4)
{
alert(mMsg + strYearMsg);
mYear.select();
return false;
}
//Checking for Numeric value for Year
for(var i=0;i<mYearValue.length;i++)
{
if(varNumeric.indexOf(mYearValue.charAt(i))
<0)
{
alert(strYearMsg);
mYear.select();
return false;
}
}
return true;
}
// Checking for ISNull
function IsNullValue(mFieldObj, mMsg)
{
var mFieldValue = mFieldObj.value;
if(mFieldValue.length<=0)
{
alert(mMsg + strIsNullMsg);
mFieldObj.select();
return false;
}
return true;
}
function IsNumeric(mFieldObj, mMsg)
{
var mFieldValue = mFieldObj.value;
//Checking for Numeric value
for(var i=0;i<mFieldValue.length;i++)
{
if(varNumeric.indexOf(mFieldValue.charAt(i))
<0)
{
alert(mMsg + strIsNumericMsg);
mFieldObj.select();
return false;
}
}
return true;
}

/*
function isSelectDateGreater(mDate,mMonth,mYear,mMsg)
{
var mMonFound=true;
var mYearFound=true;
var mFound=false;
var mFirstDate=new Date();
var mSecondDate=new Date(mMonth+mDate+", "+mYear);

//alert("Selected Year "+mSecondDate.getFullYear()
+ "---- Current Year" + mFirstDate.getFullYear());

if(mSecondDate.getFullYear() <
mFirstDate.getFullYear())
{
alert('Selected Year is lesser than Current
Year');
mYearFound = false;
}

///alert("Selected Month "+(mSecondDate.getMonth()
+1) + "---- Current Month "+(mFirstDate.getMonth()+1));


if(mSecondDate.getMonth()+1 < mFirstDate.getMonth()
+1)
{
alert('Selected Month is lesser than
Current Month');
mMonFound = false;
}

//alert("Selected Date is "+(mSecondDate.getDate
()) + "---- Current Date is "+(mFirstDate.getDate()) );


if(mSecondDate.getDate() < mFirstDate.getDate() ||
mYearFound ==false || mMonFound ==false)
{
alert('Selected Date is lesser than Current
Date');
mFound = true;
}

if(mFound)
{
alert(mMsg+strDateMsg);
return false;
}
else
return false;
}*/

function CompareDates(FromDay, FromMonth, FromYear, ToDay,
ToMonth, ToYear, mMsg)
{


var mFirstDate=new Date
(FromDay+FromMonth+", "+FromYear);
var mSecondDate=new Date(ToDay+ToMonth+", "+ToYear);

var mToCheck=true;
var permanentFalse=true;

if(mSecondDate.getFullYear()==
mFirstDate.getFullYear())
{
mToCheck=false; // check
}
else if(mSecondDate.getFullYear() <
mFirstDate.getFullYear())
{
permanentFalse=false; //out
}
else if(mSecondDate.getMonth()+1 >
mFirstDate.getMonth()+1)
{
permanentFalse=true; // ok
mToCheck==true; // ok
}

if(mToCheck==false)
{

if(mSecondDate.getFullYear()
==mFirstDate.getFullYear())
{
if(mSecondDate.getMonth()+1 ==
mFirstDate.getMonth()+1)
{
mToCheck=false; //check

//permanentFalse=false; //out
}
else if(mSecondDate.getMonth()+1 <
mFirstDate.getMonth()+1)
{
permanentFalse=false; //out
}
else if(mSecondDate.getMonth()+1 >
mFirstDate.getMonth()+1)
{
permanentFalse=true; //ok
mToCheck==true; // ok
}
}

}
if(permanentFalse==true && mToCheck==false)
{
if(mSecondDate.getMonth()+1 ==
mFirstDate.getMonth()+1)
{
if(mSecondDate.getDate() <
mFirstDate.getDate())
{
permanentFalse=false; // out
}
}
}
if(permanentFalse==false )
{
alert(mMsg);
return false;
}
else
return true;
}


//
function CompareDatesWithCurr(FromDay, FromMonth, FromYear,
mCurrentDate, mMsg)
{
if(FromDay==null || FromDay=="")
{
alert(mMsg+strIsNullMsg);
return false;
}
if(FromYear==null || FromYear=="")
{
alert(mMsg+strIsNullMsg);
return false;
}
var mFirstDate;
if(parseInt(FromDay)<1 || parseInt(FromDay) >31)
{
alert('Date should be between 1 to 31');
return false;
}
mFirstDate=new Date
(FromDay+FromMonth+", "+FromYear);

var mSecondDate=new Date(mCurrentDate);// Server
Current Date
var mToCheck=true;
var permanentFalse=true;

if( mFirstDate.getFullYear()==
mSecondDate.getFullYear())
{
mToCheck=false; // check
}
else if(mFirstDate.getFullYear() <
mSecondDate.getFullYear() )
{
permanentFalse=false; //out
}
else if(mFirstDate.getMonth()+1 >
mSecondDate.getMonth()+1 )
{
permanentFalse=true; // ok
mToCheck==true; // ok
}

if(mToCheck==false)
{

if(mFirstDate.getFullYear()
==mSecondDate.getFullYear() )
{
if(mFirstDate.getMonth()+1 ==
mSecondDate.getMonth()+1 )
{
mToCheck=false; //check

//permanentFalse=false; //out
}
else if(mFirstDate.getMonth()+1 <
mSecondDate.getMonth()+1 )
{
permanentFalse=false; //out
}
else if(mFirstDate.getMonth()+1 >
mSecondDate.getMonth()+1 )
{
permanentFalse=true; //ok
mToCheck==true; // ok
}
}

}
if(permanentFalse==true && mToCheck==false)
{
if( mFirstDate.getMonth()+1 ==
mSecondDate.getMonth()+1 )
{

if(mFirstDate.getDate() <
mSecondDate.getDate() )
{
permanentFalse=false; // out
}
}
}
if(permanentFalse==false )
{
alert(mMsg + strDateMsg);
return false;
}
else
return true;
}




// Pass strMonth as in the format of MMM Eg 'Jan', 'Feb'....
// retuns No of days in the month
function getNoOfDaysInMonth(strMonth)
{
var arr=new Array
("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct"
,"Nov","Dec");
var i=0;
var monthIndex=0;
for(i=0;i<12;i++)
{
if(arr[i]==strMonth)
{
monthIndex=i;
}
}
return DaysArray(monthIndex+1)[monthIndex+1];
}


//To Sort
function Compare2Dates(mFirstDate,mSecondDate)
{

// var mFirstDate=new Date
(FromDay+FromMonth+", "+FromYear);
// var mSecondDate=new Date(ToDay+ToMonth+", "+ToYear);
var mFirstDate=new Date(mFirstDate.substring(3,6)
+mFirstDate.substring(0,2)+", "+mFirstDate.substring(7,11));
var mSecondDate=new Date(mSecondDate.substring(3,6)
+mSecondDate.substring(0,2)+", "+mSecondDate.substring
(7,11));


var mToCheck=true;
var permanentFalse=true;

if(mSecondDate.getFullYear()==
mFirstDate.getFullYear())
{
mToCheck=false; // check
}
else if(mSecondDate.getFullYear() <
mFirstDate.getFullYear())
{
permanentFalse=false; //out
}
else if(mSecondDate.getMonth()+1 >
mFirstDate.getMonth()+1)
{
permanentFalse=true; // ok
mToCheck==true; // ok
}

if(mToCheck==false)
{

if(mSecondDate.getFullYear()
==mFirstDate.getFullYear())
{
if(mSecondDate.getMonth()+1 ==
mFirstDate.getMonth()+1)
{
mToCheck=false; //check

//permanentFalse=false; //out
}
else if(mSecondDate.getMonth()+1 <
mFirstDate.getMonth()+1)
{
permanentFalse=false; //out
}
else if(mSecondDate.getMonth()+1 >
mFirstDate.getMonth()+1)
{
permanentFalse=true; //ok
mToCheck==true; // ok
}
}

}
if(permanentFalse==true && mToCheck==false)
{
if(mSecondDate.getMonth()+1 ==
mFirstDate.getMonth()+1)
{
if(mSecondDate.getDate() <
mFirstDate.getDate())
{
permanentFalse=false; // out
}
}
}

if(permanentFalse==false )
{
// alert(mMsg);
return false;
}
else
return true;
}

// This function returns 0 if the given dates are not
fallen inbetween
function compareDatesInBetween
(mDate,mNextDate,mCompareDate,mDateFormat)
{
try
{
var mDateFt = getDateFromFormat(mDate,
mDateFormat);
var mDateNxtFt = getDateFromFormat
(mNextDate, mDateFormat);
var mDateCprFt = getDateFromFormat
(mCompareDate, mDateFormat);

if (mDateFt==0 || mDateNxtFt==0)
{
return -1;
}

if (mDateFt <= mDateCprFt && mDateNxtFt
>=mDateCprFt)
{
return 1;
}
return 0;
}
catch(mErr)
{
//alert(mErr.message);
}
}
// compareDateInBetween - end


//Added By Deepesh For Validation Fields With Certain
Exceptions in Values and Numbers not allowed.
//Allowing charcters like . ,
function AlphabetsWithExcep_onkeypress(v)
{
if (window.event.keyCode != 32)
{
if(window.event.keyCode<65 ||
window.event.keyCode>90)
{
if(window.event.keyCode<97 ||
window.event.keyCode>122 )
{
if(!((window.event.keyCode
== 46) || (window.event.keyCode== 44)) )
{

window.event.keyCode=false
return false
}
}
}
}
}
//Added By Deepesh For Validation Fields With Certain
Exceptions in Values and Numbers are allowed.
//Allowing charcters like / . , + - ( )
function AlphaNumWithExcep_onkeypress(v)
{
if (window.event.keyCode != 32)
{
if(window.event.keyCode<48 ||
window.event.keyCode>58 )
{
if(window.event.keyCode<65 ||
window.event.keyCode>90)
{
if(window.event.keyCode<97
|| window.event.keyCode>122 )
{
if(!
((window.event.keyCode == 47) ||(window.event.keyCode ==
46) || (window.event.keyCode== 44) || (window.event.keyCode
== 43) || (window.event.keyCode == 45) ||
(window.event.keyCode == 40) || (window.event.keyCode ==
41)) )
{

window.event.keyCode=false
return
false
}
}
}
}
}
}

//allows .
function allowNumbersOnly_onkeypress(p)
{

if (window.event.keyCode != 32)
{

if(window.event.keyCode<48 ||
window.event.keyCode>=58 )
{
if(!(window.event.keyCode == 46))
window.event.keyCode=false
return false
}
}
}

//Added By Jeyaprakash
function AlphaNumWithExcep(mObj)
{
for(var
intLoop=0;intLoop<mObj.value.length;intLoop++)
{
ch=mObj.value.charCodeAt(intLoop);
if (ch != 32)
{
if(ch<48 || ch>58 )
{
if(ch<65 || ch>90)
{
if(ch<97 || ch>122 )
{
if(!((ch ==
47) ||(ch == 46) || (ch== 44) || (ch == 43) || (ch == 45)
|| (ch == 40) || (ch == 41)) )
{

alert("Kindy enter only permitted Spl. Characters");

return false;
}
}
}
}
}
}
return true;
}

//Added By Jeyaprakash
function AlphabetsWithExcep(mObj)
{
for(var
intLoop=0;intLoop<mObj.value.length;intLoop++)
{
ch=mObj.value.charCodeAt(intLoop);
if (ch != 32)
{
if(ch<65 || ch>90)
{
if(ch<97 || ch>122 )
{
// if(!((ch == 47) ||
(ch == 46) || (ch== 44) || (ch == 43) || (ch == 45) || (ch
== 40) || (ch == 41)) )
// {
alert
("Kindy enter only Alphabets");
return
false;
// }
}
}
}
}
return true;
}


//will allow special characters +,-,),(,space
function allowNumbersWithExcep_onkeypress(p)
{

if (window.event.keyCode != 32)
{
if(window.event.keyCode<48 ||
window.event.keyCode>=58 )
{
if(!((window.event.keyCode == 45)
|| (window.event.keyCode == 43) || (window.event.keyCode
== 44) || (window.event.keyCode == 40) ||
(window.event.keyCode == 41)))
{

window.event.keyCode=false
return false
}
}
}
}

//For Dates With Three TextBoxes
function DateBox_onkeypress(p)
{

if (window.event.keyCode != 32)
{

if(window.event.keyCode<48 ||
window.event.keyCode>=58 )
{
window.event.keyCode=false
return false
}
}
}


//Added By Jeyaprakash
function chkemail(str)
{
//regexp=/[^@.]+@+[^@.]+\.+[^@.]/
regexp=/^[a-z][\w\.]*@[\w\.]+\.[a-z]{2,3}/i
return regexp.test(str)
}

//Added By Jeyaprakash
//Function to Set Variable to say page content get modified
function setPageModified(fieldName)
{
document.getElementById(fieldName).value=1;
}

//Added By Jeyaprakash
//Function to throw alert if a page content not changed
function isPageModified(fieldName)
{
if (document.getElementById(fieldName).value == 0)
{
alert("No Modifications Done.Kindly Change
any values and submit Or Click Discard");
return false;
}
else
return true;
}

function ListBoxSelection(comboCtrl,mMsg1)
{
if(comboCtrl.options.selectedIndex<0)
{
alert( strComboSelMsg + mMsg1);
comboCtrl.select;
comboCtrl.focus();
return false;
}
else
return true;
}

function CheckListSelection(comboCtrl,mMsg1)
{
if(comboCtrl.options.selectedIndex<0)
{
alert(strComboSelMsg + mMsg1);
return false;
}
else
return true;
}

function compareDatesWithFormatsCurr1
(date1,dateformat1,date2,dateformat2)
{
var ArrdtFormat1;
var ArrdtFormat2;
if((dateformat1 == "dd-MMM-yyyy") &&
(dateformat2=="dd-MMM-yyyy"))
{
ArrdtFormat1=date1.split("-");
if(ArrdtFormat1[0].length==1)
date1="0"+ArrdtFormat1[0]+"-
"+ArrdtFormat1[1]+"-"+ArrdtFormat1[2];

ArrdtFormat2=date2.split("-");
if(ArrdtFormat2[0].length==1)
date2="0"+ArrdtFormat2[0]+"-
"+ArrdtFormat2[1]+"-"+ArrdtFormat2[2];
}

var d1=getDateFromFormat(date1,dateformat1);
var d2=getDateFromFormat(date2,dateformat2);


if (d1==0 || d2==0)
{
return -1;
}
else if (d1 > d2)
{

return 1;
}
return 0;
}


function compareDatesWithFormatsCurr
(date1,dateformat1,date2,dateformat2)
{
var ArrdtFormat1;
var ArrdtFormat2;
if((dateformat1 == "dd-MMM-yyyy") &&
(dateformat2=="dd-MMM-yyyy"))
{
ArrdtFormat1=date1.split("-");
if(ArrdtFormat1[0].length==1)
date1="0"+ArrdtFormat1[0]+"-
"+ArrdtFormat1[1]+"-"+ArrdtFormat1[2];

ArrdtFormat2=date2.split("-");
if(ArrdtFormat2[0].length==1)
date2="0"+ArrdtFormat2[0]+"-
"+ArrdtFormat2[1]+"-"+ArrdtFormat2[2];
}

var d1=getDateFromFormat(date1,dateformat1);
var d2=getDateFromFormat(date2,dateformat2);


if (d1==0 || d2==0)
{
return -1;
}
else if (d1 >= d2)
{

return 1;
}
return 0;
}


//Added by Jeyaprakash - To Show Form Details
function OpenFormDetailsWindow(URL)
{
//URL="../ADNETMASTERS/DisplayFormDetails.aspx?
Form_ID="+document.getElementById("txtFormName").value;
window.open
(URL,"FormDetails","width=550,height=450,left=420");

}

//Added by Jeyaprakash - To Show APPROVER COMMENTS
function doShowApproverComments(mFlowID)
{
var mFilenameArr = new Array();
mFilenameArr=window.document.parentWindow.parent.loc
ation.pathname.split("/");
//window.open
("http://"+window.location.host+"/"+mFilenameArr[1]
+"/TRAVELREQUEST/Track_Approver_Comments.aspx?
mFlowID="+mFlowID,"ApproverComments","width=600,height=500,l
eft=300,top=100");
window.open
("http://"+window.location.host+"/"+mFilenameArr[1]
+"/Track_Approver_Comments.aspx?
mFlowID="+mFlowID,"ApproverComments","width=600,height=500,l
eft=300,top=100");
}


//Added by Jeyaprakash - To Show Page in full screen
function doShowFullScreen()
{
top.mainframeset.cols="1,*";
}

//Added by Jeyaprakash - To Show Left Tree
function doShowLeftTree()
{
top.mainframeset.cols="215,*";
}

function CharacterLeft(obj,maxlen)
{
inputStr = document.getElementById(obj).value;
strlength= inputStr.length;
if (strlength > maxlen )
{
document.getElementById
(obj).value=inputStr.substring(0,maxlen);
document.getElementById(obj).focus();
}
}

//Added by Jeyaprakash - To Validate Currency

function validateCurrency(obj)
{
/* NullValidation(obj,"Currency");
if (varBroken==1)
{
document.getElementById
("hdnError").value="yes";
return false;
}*/
if (isNaN(obj.value))
{
document.getElementById
("hdnError").value="yes";
alert("Kindly enter only numeric
values in Amount");
return false;
}

if (obj.value.length > 0)
{
obj.value = obj.value * Math.pow
(10, 2)
obj.value = Math.round(obj.value)
obj.value = obj.value / Math.pow
(10, 2)

obj.value=parseFloat(obj.value);
}

/* if (obj.value <= 0)
{
document.getElementById
("hdnError").value="yes";
alert("Kindly enter Amount value
greater than zero");
obj.focus();
return false;
}*/


var strPosition=obj.value.indexOf(".");
if (obj.value.lastIndexOf(".") !=
strPosition)
{
document.getElementById
("hdnError").value="yes";
alert("Kindly enter only one '.' in
Amount");
obj.focus();
return false;
}
if (strPosition > 0)
{
if (obj.value.length > 11)
{
document.getElementById
("hdnError").value="yes";
alert("Kindly enter Amount
Less than 99999999.99");
obj.focus();
return false;
}
else
{
if(obj.value.substring
(0,strPosition).length > 8)
{

document.getElementById("hdnError").value="yes";
alert("Kindly enter
Amount Less than 99999999.99");
obj.focus();
return false;
}
if (obj.value.substring
(strPosition+1,obj.value.length).length > 2)
{

document.getElementById("hdnError").value="yes";
alert("Kindly enter
decimal value Less than two digits");
obj.focus();
return false;
}

}
}
else
{
if (obj.value.length > 8)
{
document.getElementById
("hdnError").value="yes";
alert("Kindly enter Amount
Less than 99999999.99");
obj.focus();
return false;
}
}
document.getElementById
("hdnError").value="no";
return true;
}


//Added by SATHYA(CCIPL)
//Validation for Alphabets only which does not allow
special characters


function AlphabeticCharactersOnly_onkeypress(s)
{

if(window.event.keyCode < 65 || window.event.keyCode >
90)
{
if(window.event.keyCode < 97 ||
window.event.keyCode > 122)
{
window.event.keyCode=false;
return false;
}

}
}


//Added by SATHYA(CCIPL)
//modified by Murali Krishnan(ccipl)

//Validation for numbers only without any other Special
characters and blank space
function NumbersOnly_onkeypress(p)
{
if(window.event.keyCode<48 ||
window.event.keyCode>57)
{
window.event.keyCode=false
return false
}

}



//added by Murali Krishnan(ccipl)
//Validating E-Mail address
function ValidateMail(textvalue)
{
sValidMailStr = "Enter a valid Email Id";
sEmptyEmailStr = "Email cannot be left empty";
invalidchars="\"~ !#$%^&*()-+=|\\{}[]:;'<>?,/`";
var temp = 0;
tempValue=textvalue;
sEmail=tempValue.value.toLowerCase();
var iLength = sEmail.length;


if( iLength < 1 || sEmail.value == " ")
{
//alert("blank id");
return false;
}

if (parseInt(sEmail.charAt(0))>=0 || parseInt
(sEmail.charAt(0))<=9)
{
alert("First character cannot be a Number
in email address");
return false;
}
for(i=0;i<sEmail.length;i++)
{
for(j=0;j<invalidchars.length;j++)
{
if(sEmail.charAt(i)
==invalidchars.charAt(j))
{
alert("Your email contains
a blank space or special character.");
return false;
}
}
}
var dotpos = sEmail.indexOf(".",0);
var atpos = sEmail.indexOf("@",0);

if(dotpos == 0 || atpos == 0 || atpos == (iLength-
1) || dotpos == (atpos+1) )
{
alert("Kindly check position of '@' and '.'
in email address");
return false;
}

for(i=0;i<sEmail.length;i++)
{
if (sEmail.charAt(i)=="@")
{
if((i!=0) && (sEmail.charAt(i-1)
=="."))
{
alert("Kindly note '.'
cannot come immediately before '@'");
return false;
}
temp = temp + 1;
}
}
if ( (temp>1) )
{
alert("E-mail address contains extra '@'
character ");
return false;
}
if( (temp==0) )
{
alert("Kindly check for '@' character in E-
mail address ");
return false;
}
var strafterAt = sEmail.substring(sEmail.indexOf
("@",0), iLength);
for(i=0; i<strafterAt.length; i++)
{
if(strafterAt.charAt(i) == '_')
{
alert(" Kindly note '_' character
is not allowed after '@'");
return false;
}
}
for (i=0; i<=sEmail.length; i++)
{
if (sEmail.charAt(i)=="." && sEmail.charAt
(i+1)==".")
{
alert("Kindly note '.' characters
cannot be given continuously");
return false;
}
}
var strafterDot = sEmail.substring(sEmail.indexOf
(".",0),sEmail.iLength-1);

if (strafterDot.length == 0)
{
alert("Kindly enter domain name");
return false;
}
if(sEmail.lastIndexOf(".") == iLength-1)
{
alert("Kindly enter domain name");
return false;
}
else
{
var finalstr = sEmail.substring
((sEmail.lastIndexOf("."))+1,iLength);

for(i=0; i<finalstr.length; i++)
{
if (parseInt(finalstr.charAt(i))>=0
|| parseInt(finalstr.charAt(i))<=9)
{
alert("Kindly note numbers
are not allowed in domain name");
return false;
}
}

if(finalstr.length<2)
{
alert("Domain name must end
with well known domains \n or 2-lettered country name. eg
com,edu,in etc.")
return false
}
else
{

var domain = finalstr;

dom=new Array
("au","com","net","org","edu","in","mil","gov","arpa","biz",
"aero","name","coop","info","pro","museum")
error="yes"
for(var
k=0;k<dom.length;k++)
{
if(domain==dom[k])
{
k=dom.length
error="no"
}
}
if((error=="yes" &&
(domain.length>=2)) || (domain.length<2))
{
alert("Domain name
must end with well known domains \n or 2-lettered country
name. eg com,edu,in etc.")
return false
}

}
}

return true;
}


//Added by Murali Krishnan(CCIPL)
//Validation for Alphabets and blankspace which will not
allow other characters
//Modified by BharathiRaja(CCIPL)
//No Blank Space for First Character in the InputBox.
function AlphabetsBlank_onkeypress(txtval)
{ var n=txtval.value;
var n1=n.length

if(window.event.keyCode != 32 || n1==0)
{
if(window.event.keyCode < 65 ||
window.event.keyCode > 90)
{
if(window.event.keyCode < 97 ||
window.event.keyCode > 122)
{

window.event.keyCode=false;
return false;
}
}
}

}
//Added by Prabhakaran(CCIPL)
//Validation to check the Input number format as ###.##

function NumberDecimalValid(textvalue)
{
var str,iLoop,iNumAscii,iNumValue,dotposition;
var cnt=0;
var totdigit=0;
str=textvalue;
iNumVal=str.charAt(0);
iNumAsc=iNumVal.charCodeAt(0);

if (((iNumAsc==43))|| ((iNumAsc>=48 && iNumAsc<=57 )))
{
if(str.length==1)
return false;
for( iLoop=1; iLoop<str.length;iLoop++)
{

iNumValue=str.charAt(iLoop);
iNumAscii=iNumValue.charCodeAt(0);

if(iNumAscii==46)
{ cnt++; }
if ((iNumAscii<46)||(iNumAscii>46 && iNumAscii<48)
|| (iNumAscii>57)||(cnt>1))
{
return true;
break;
}
else if(cnt==1)
{
dotposition=str.indexOf(".");
totdigit=str.substring
(dotposition+1,str.length);
if(((totdigit.length)>2)||
(dotposition+1==str.length))
{
return false;
break;
}
}
}
}
else
return false;
return true;
}


//Added by Ganesh(CCIPL)
//T0 reduce two days from the given input date.


function FormatDate(DateToFormat,FormatAs)
{
if(DateToFormat==""){return"";}
if(!FormatAs){FormatAs="dd/mm/yyyy";}

var strReturnDate;
FormatAs = FormatAs.toLowerCase();
DateToFormat = DateToFormat.toLowerCase();
var arrDate
var arrMonths = new Array
("January","February","March","April","May","June","July","A
ugust","September","October","November","December");
var strMONTH;
var Separator;

while(DateToFormat.indexOf("st")>-1){
DateToFormat = DateToFormat.replace("st","");

Is This Answer Correct ?    0 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

I am getting the "test object property" Description properties "toolkit class" value By using "gettoproperty" in run time But my problem is how to get Ordinal Identyfier's type and value Type is index, value is 0 How can i keep this values in to required place How can i get these values in runtime I have to insert these "index" and "value" into another area Is there any script for this like "gettoproperties","Getroproperties" If anybody knows,please help me .

1819


What is regular expression?

676


How you are developing the script? Using record and play back or manual?

703


WHAT IS THE DIFFERENCE BETWEEN QTP SCRIPT AND VB SCRIPT? HOW MUCH PERCENTAGE WE USE IN QTP SCRIPT REAL TIME AND HOW MUCH PERCEN OF VB SCRIPT,,,,,,,

1620


write a script to validate the content in the web application. (do it by OR method) and (do it by Descriptive method by creating a description object.. (give a filter condition only WEbelement- not easy need to use some more property while giving filter condtions- use google for your help...))

1597






What is the difference between shared and local object repository?

697


There is an built in window application in qtp9.1,i.e.Flight4.0.i want to implement the recovery maneger on it.How can i do this?

1712


if numbers are always changing write a script for that

3579


What is reusable action?

691


An action has both shared and local or associated to it and both have the same object in them. In the test which one will be considered?

745


Why is Client side image is preferred over server side image?

1543


I am getting an error "failed to open the XML checkpoint result viewer" in result window,after clicking on "View XML checkpoint results".Someone suggest me settings,if any...

1558


what is vmodel?advantages and disadvantages of vmodel?

1701


What are the Disadvantages of shared object repository?

668


What is the differences between image check point and bit map check point?

661