HTML Form:
<form
name="CheckIn"
method="post"
action="check.asp"
onsubmit="return CheckBreakTime() && CheckTime();"
>
I call two functions whit onsubmit,the functions return true or false,but function works only if it's "first" ,for example if i say ' onsubmit="return CheckTime() && CheckBreakTime();" ' only CheckTime works if i call ChecKBreakTime first it only works.
The Functions (JavaScript) :
function CheckBreakTime(){
if (document.getElementById('breakco').checked) {
var BKTimeDif1 = '<%=BTimeDif%>';
var var1 = 20 ;
var sum1 = var1 - BKTimeDif1 ;
if (BKTimeDif1 > 10 && BKTimeDif1 < 21) {
alert("You were on a break longer than 10 minutes,You must wait " + sum1 + " minutes to pass to check out from break. ");
return false;
} else {
return true;
}
}
else {
return true;
}
}
function CheckTime() {
if (document.getElementById('breakci').checked) {
var TimeDif2 = '<%=BTimeDiff%>';
var TimeDif1 = '<%=TimeDif%>';
if (TimeDif1 < 120) {
alert("You must work at least two hours before you can go on a break.");
return false;
} else {
if (TimeDif2 != 0 && TimeDif2 < 120) {
alert("You must work at least two hours before you can go on another break.");
return false;
}
else {
return true;
}
}
}
else {
return true;
}
}
and the VBScript code that i put in JavaScript:
Dim TimeDif
TimeDif=Round(Csng(DateDiff("n", (HourList.Fields.Item("checkInTime").Value), (Now()))), 2)
Dim BTimeDif
If Not IsNull(HourList.Fields.Item("breakCheckIn").Value) Then
BTimeDif = Round(Csng(DateDiff("n", (HourList.Fields.Item("breakCheckIn").Value), (Now()))), 2)
End If
If Not IsNull(HourList.Fields.Item("breakCheckOut").Value) Then
Dim BTimeDiff
BTimeDiff = Round(Csng(DateDiff("n", (HourList.Fields.Item("breakCheckOut").Value), (Now()))), 2)
End If
VBScript code works fine,it returns what it need to and JavaScript gets it.Can some tell me what is the problem...