The-Morg
11-30-2003, 05:16 PM
Hey-
New to the forum, just had a question about a simple little validation script for user entered time. The script checks for a colon (:) somewhere in the time which the user enters.
The problem is that I get no window alert even if I do not use a colon.
It is probably something simple that I am overlooking... anyone see it?
<html>
<head>
<title>Project 14-1</title>
<script language="JavaScript">
<!--
function checkTime()
{
var result=true;
if (document.form1.theTime.value.indexOf(":") == -1)
{
result=false;
window.alert("Sorry, your time must contain a colon /(:/), please try again.");
}
return result;
}
//-->
</script>
</head>
<body onLoad="document.form1.theTime.focus();">
<form name="form1" action="#">
What time is it?<br>
<input type="text" name="theTime"><p>
<input type="submit" value="Submit" name="submitForm" onSubmit="return checkTime();">
</form>
</body>
</html>
Thanks guys!
New to the forum, just had a question about a simple little validation script for user entered time. The script checks for a colon (:) somewhere in the time which the user enters.
The problem is that I get no window alert even if I do not use a colon.
It is probably something simple that I am overlooking... anyone see it?
<html>
<head>
<title>Project 14-1</title>
<script language="JavaScript">
<!--
function checkTime()
{
var result=true;
if (document.form1.theTime.value.indexOf(":") == -1)
{
result=false;
window.alert("Sorry, your time must contain a colon /(:/), please try again.");
}
return result;
}
//-->
</script>
</head>
<body onLoad="document.form1.theTime.focus();">
<form name="form1" action="#">
What time is it?<br>
<input type="text" name="theTime"><p>
<input type="submit" value="Submit" name="submitForm" onSubmit="return checkTime();">
</form>
</body>
</html>
Thanks guys!