right now i have these 2 text fields...
Code:
<%if v_cnt mod 2 = 0 then%> <td align="center"><INPUT type="text" name=txtClockTime maxlength=5 size=5 value="<%=formatdatetime(v_HistTime,4)%>" style="font-family : Tahoma, Sans-Serif, Verdana, Geneva, Arial, Helvetica; background:#F2F5FE; font-size : 8pt; color: #31345C"></td> <td width="11"><img src="/images/control/eTimeClock/div.gif"></td> <%else%> <td align="center"><INPUT type="text" name=txtClockTime maxlength=5 size=5 value="<%=formatdatetime(v_HistTime,4)%>" style="font-family : Tahoma, Sans-Serif, Verdana, Geneva, Arial, Helvetica; background:#F2F5FE; font-size : 8pt; color: #31345C"></td> <td width="11"><img src="/images/control/eTimeClock/div.gif"></td> <%end if%>
Code:
function ValidateTime(){
// Checks if time is in HH:MM format.
//Clock-in time
var i = 0
timeStr = document.Report.txtClockTime(0).value;
var timePat = /^(\d{1,2}):(\d{2})?$/;
var matchArray = timeStr.match(timePat);
if (matchArray == null) {
alert("Clock-In time must be in a valid format(HH:MM).");
return false;
}
hour = matchArray[1];
minute = matchArray[2];
if (hour < 0 || hour > 23) {
alert("Clock-In hour must be between 0 and 23.");
return false;
}
if (minute<0 || minute > 59) {
alert ("Clock-In minute must be between 0 and 59.");
return false;
}
//Clock-Out time
i = 1
timeStr = document.Report.txtClockTime(1).value;
var timePat = /^(\d{1,2}):(\d{2})?$/;
var matchArray = timeStr.match(timePat);
if (matchArray == null) {
alert("Clock-Out time must be in a valid format(HH:MM).");
return false;
}
hour = matchArray[1];
minute = matchArray[2];
if (hour < 0 || hour > 23) {
alert("Clock-Out hour must be between 0 and 23.");
return false;
}
if (minute<0 || minute > 59) {
alert ("Clock-Out minute must be between 0 and 59.");
return false;
}
var sClockin = document.Report.txtClockTime(0).value
var sClockout = document.Report.txtClockTime(1).value
sClockin = sClockin.replace(/:/gi,"");
sClockout = sClockout.replace(/:/gi,"");
if (parseInt(sClockout) < parseInt(sClockin))
{
//alert(parseInt(sClockout));
//alert(parseInt(sClockin));
alert ("Clock-Out time must be greater than or equal to Clock-In time");
return false;
}
}
