Thursday, March 4, 2010


Javascript Issue

function ValidateLeave()

{

var LeaveCount=document.getEl("txtTotalLeaves");

var Days=document.getEl("txtDays");

if( LeaveCount.value==0)

{

alert("Sorry You Have No Leaves Available");

return false;

}

else if (LeaveCount.value < Days.value)

{

alert(LeaveCount.value);

alert(Days.value);

alert("Sorry!Check your available leaves!");

return false;

}

else

{

return true;

}

}

The above code throws error for me, the issue came because of wrong type casting.Here is an useful link for type casting www.jibbering.com#tcInt

The below code will work fine.

function ValidateLeave()

{

var LeaveCount=document.getEl("txtTotalLeaves");

var Days=document.getEl("txtDays");

if( LeaveCount.value*1==0)

{

alert("Sorry You Have No Leaves Available");

return false;

}

else if (LeaveCount.value*1 < Days.value*1)

{

alert(LeaveCount.value);

alert(Days.value);

alert("Sorry!Check your available leaves!");

return false;

}

else

{

return true;

}

}



AddThis Social Bookmark Button

2 comments:

Unknown said...

All of these books are sorted by title.over here FullBooks.com also has links to sites with free reference books biographies and science books.

Universal Teacher said...

thanks for sharing useful post and great blog

By Lily
Free Online Articles, Articles and Tips