function ValidatePhaseEdit (gvProjectPhaseEdit) { var msg=""; var grid = document.getElementById(gvProjectPhaseEdit); var ReqStartDate_txt; var ReqFinishDate_txt; var ActualCompleteDate_txt; var Comments_txt; var ReqStartDate_val; var ReqFinishDate_val; var ActualCompleteDate_val; var Comments_val; // The number of milliseconds in one day var ONE_DAY = 1000 * 60 * 60 * 24; var date = new Date(); var curdatebuf = (date.getMonth()+1)+"/"+date.getDate()+"/"+date.getFullYear(); var curdate = new Date(curdatebuf); var timediff; var difference_day; if (grid.rows.length > 0) { //loop starts from 1. rows[0] points to the header. for (i = 1; i < grid.rows.length; i++) { ReqStartDate_txt = grid.rows[i].cells[13]; ReqFinishDate_txt = grid.rows[i].cells[14]; ActualCompleteDate_txt = grid.rows[i].cells[15]; Comments_txt = grid.rows[i].cells[18]; //alert("ReqStartDate_txt.childNodes.length"+ReqStartDate_txt.childNodes.length); for (j = 0; j < ReqStartDate_txt.childNodes.length; j++) { //alert("ReqStartDate_txt.childNodes[j].type"+ReqStartDate_txt.childNodes[j].type); if (ReqStartDate_txt.childNodes[j].type == "text") { // alert("i"+i); // alert("j"+j); ReqStartDate_val = ReqStartDate_txt.childNodes[j].value; // alert("ReqStartDate_val"+ReqStartDate_val); } } for (j = 0; j < ReqFinishDate_txt.childNodes.length; j++) { if (ReqFinishDate_txt.childNodes[j].type == "text") { ReqFinishDate_val = ReqFinishDate_txt.childNodes[j].value; //alert(ReqFinishDate_val); } } for (j = 0; j < ActualCompleteDate_txt.childNodes.length; j++) { if (ActualCompleteDate_txt.childNodes[j].type == "text") { ActualCompleteDate_val = ActualCompleteDate_txt.childNodes[j].value; //alert(ActualCompleteDate_val); } } for (j = 0; j < Comments_txt.childNodes.length; j++) { if (Comments_txt.childNodes[j].type == "text") { Comments_val = Comments_txt.childNodes[j].value; //alert(Comments_val); } } // alert("i"+i); // alert("ReqStartDate_val"+ReqStartDate_val) // alert("ReqFinishDate_val"+ReqFinishDate_val); if (ReqStartDate_val=="" || ReqFinishDate_val=="") { if(Comments_val!="") { msg+="You can not enter comment without entering Required Start Date and Required Finish Date at Line "+i+".\n"; Comments_txt.value=""; } if(ActualCompleteDate_val!="") { msg+="You can not enter Actual Complete Date without entering Required Start Date and Required Finish Date at Line "+i+".\n"; } } if (ReqStartDate_val!="") { if (isDate(ReqStartDate_val)) { } else { msg+="Please enter a valid Req Start Date at Line "+i+".\n"; } } if (ActualCompleteDate_val!="") { if (isDate(ActualCompleteDate_val)) { } else { msg+="Please enter a valid Actual Complete Date at Line "+i+".\n"; } } if (ReqFinishDate_val!="") { if(isDate(ReqFinishDate_val)) { var ReqFinDate = new Date(ReqFinishDate_val); // alert("i"+i); // Calculate the difference in milliseconds timediff = DateDiff(ReqFinDate,curdate); // alert("timediff"+timediff); // Calculate the number of days difference_day = Math.floor(timediff / ONE_DAY); // alert("difference_day"+difference_day); if (difference_day<15) { // alert("Inside if block difference_day<15"); //Let the user enter comment-- do nothing } else { if (Comments_val!="") { // alert("Inside else block"); msg+="Comment can not be entered at Line "+i+".\n"; Comments_txt.value=""; } } } else { msg+="Please enter a valid Req Finish Date at Line "+i+".\n"; } } } } if (msg!="") { alert(msg); return false; } else { if (confirm("Are you sure, you want to save the data?")) { return true; } else { return false; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)