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; } } |
Thursday, March 4, 2010
Javascript Issue
Posted by Mr.Late at 3:37 AM
Subscribe to:
Post Comments (Atom)
2 comments:
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.
thanks for sharing useful post and great blog
By Lily
Free Online Articles, Articles and Tips
Post a Comment