JavaScript Tutorial/Document/Tag Reference
Get form TextField value
<HTML>
<HEAD>
<SCRIPT language="JavaScript">
<!--
function check_it()
{
var thetext=document.myForm.the_time.value;
if (thetext.indexOf("a") == -1)
{
window.alert("a should in between");
return false;
}
else
{
return true;
}
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<FORM name="myForm" action="#" onSubmit="return check_it();">
What time is it?<BR>
<INPUT type="text" name="the_time">
<BR>
<INPUT type="submit" value="Submit">
</BODY>
</HTML>
Reference your tags in document
<HTML>
<HEAD>
<SCRIPT language="JavaScript">
<!--
function newpage()
{
var thename= document.myform.yourname.value;
var thefood= document.myform.yourfood.value;
document.open();
document.write("Your name is "+thename);
document.write("<BR>");
document.write("Your favorite food is "+thefood);
document.close();
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<FORM name="myform">
Name: <INPUT type="text" name="yourname" size="25">
<P>
Favorite Food: <INPUT type="text" name="yourfood" size="25">
<P>
<INPUT TYPE="button" value="Click Here for a New Page" onClick="newpage()">
</FORM>
</BODY>
</HTML>