javascript help !

im kinda unsure where this post should go... but here goes...

right now i have these 2 text fields...

<%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%>

and i have this function to check for it...

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;
}
}

it's actually some kind of clocking system that allows people to clock in and out to keep track of their working hours and stuff... right now it only checks for 1st set of clock in and out... i wanna change it such that it checks for more than the 2 entries in cases where there are multiple entries and i dont know how... desperate for help =(
[3133 byte] By [aicirt] at [2007-11-19 23:45:12]
# 1 Re: javascript help !
How much do you know about programming? The reason I ask is because in order for this script to do multiple punchins and outs, you are going to have to do a lot of changes. Enough changes to make it easier just to write your own.

Also, there are a lot of parts missing. It is getting the time from a textbox on the html page. Now, what is the security behind this? If the clock is JavaScript and not taken from the database, anyone can fake his/her time.

I suggest that you make sure it is grabbing the server time. It seems that you have some ASP in there. That would be where to check.
PeejAvery at 2007-11-8 0:40:44 >
# 2 Re: javascript help !
yeah i realised that its gonna be a lot to change and that's the big problem. i don't really know how to start even... and regarding the security stuff... this is only accessable by admin so it's quite ok...
aicirt at 2007-11-8 0:41:36 >
# 3 Re: javascript help !
and regarding the security stuff... this is only accessable by admin so it's quite ok...
No. That is not true. If it is a web-based application, it is never only accessible to the admin.

Here are some questions to ask yourself.
1. Is the time acquired from the server or from the client?
2. If from the server, does the punch-in come from a web form?
3. If so, what is to keep the user from making a mock form on his local machine?
4. Do you have server sessions to keep that from happening?

Personally, I would suggest looking into a different clock in application.
PeejAvery at 2007-11-8 0:42:47 >