I have this script, it works really good in a normal PHP form but it doesn’t work in ScriptCase form. Can someone help me?
var st;
var stsplt;
var ftsplt;
var passflag;
function chkstart () {
var flag = 0;
st = document.myform.startTime.value;
st = st.replace(/[.-]/,":");
if (!/d{1,2}:d{2}/.test(st)) {
flag ++;
}
stsplt = st.split(":");
stsplt[0] = stsplt[0] * 1;
stsplt[1] = stsplt[1] * 1;
if ((stsplt[0] < 0) || (stsplt [0] > 23)) {
flag ++;
}
if ((stsplt[1] < 0) || (stsplt [1] > 59)) {
flag ++;
}
if (flag > 0) {
alert ("Invalid time - please re-enter! ");
flag = 0;
document.myform.startTime.value = “”;
document.myform.startTime.focus();
return false;
}
else {
passflag = 1;
}
}
function calcDiff () {
if (passflag != 1) {
alert (“You must enter a starting time!” );
document.myform.startTime.value = “”;
document.myform.startTime.focus();
return false;
}
var flag = 0;
var ft = document.myform.finishTime.value;
ft = ft.replace(/[.-]/,":");
if (!/d{1,2}:d{2}/.test(ft)) {
flag ++;
}
ftsplt = ft.split(":");
ftsplt[0] = ftsplt[0] * 1;
ftsplt[1] = ftsplt[1] * 1;
if ((ftsplt[0] < 0) || (ftsplt [0] > 23)) {
flag ++;
}
if ((ftsplt[1] < 0) || (ftsplt [1] > 59)) {
flag ++;
}
if (ftsplt[0] < stsplt[0]) {
flag ++;
}
if ((ftsplt[0] == stsplt[0]) && (ftsplt[1] > stsplt[1])) {
flag ++;
}
if (flag > 0) {
alert ("Invalid time - please re-enter! ");
flag = 0;
document.myform.finishTime.value = “”;
document.myform.finishTime.focus();
return false;
}
var hrsDiff = ftsplt[0] - stsplt[0];
if (ftsplt[1] < stsplt[1]) {
hrsDiff = hrsDiff -1;
alert (hrsDiff)
}
var minsDiff = ftsplt[1] - stsplt[1];
if (minsDiff < 0) {
minsDiff = 60 + minsDiff;
}
if (minsDiff < 10) {
minsDiff = “0” + minsDiff;
}
var diffTime = hrsDiff + “:” + minsDiff;
document.myform.timeDiff.value = diffTime;
}