/*
JavaScript: A Beginner's Guide, Second Edition
By John Pollock
Publisher: McGraw-Hill,
Published December 2003, 550 pages,
ISBN 0072227907
*/
<HTML>
<HEAD>
<SCRIPT language="JavaScript">
<!--
function check_it()
{
var thetext=document.f1.the_time.value;
if (thetext.indexOf(":") == -1)
{
window.alert("Sorry, the time needs to have a colon (:) to be valid. Try again.");
return false;
}
else
{
return true;
}
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<FORM name="f1" action="#" onSubmit="return check_it();">
What time is it?<BR>
<INPUT type="text" name="the_time">
<BR>
<INPUT type="submit" value="Submit">
</BODY>
</HTML>
|