What's wrong with the following code? Header is a text box...
<?php
<script language="javascript\">
function isFilledHeader()
{
if(document.AddForm.Header.Header == \"\");
{
alert('You must complete the Header field');
return false
}
}
</script>
?>
When I try to run it it always returns false and generates the error. What am I doing wrong here?
Thanks for your help.






John Pollock posted this at 20:18 — 7th December 2001.
He has: 628 posts
Joined: Mar 1999
Just a guess, but try changing:
document.AddForm.Header.Header
to
document.AddForm.Header.value
If that doesn't work post back with the form/text box code also.
Java Script: A Beginner's Guide
Page Resource
artsapimp posted this at 21:14 — 7th December 2001.
They have: 330 posts
Joined: Apr 2000
I rewrote it here before which is why that was not correct. I had that correct in my app.
<?php<script language="javascript\">
function isFilledHeader()
{
if(document.AddForm.Header.value == \"\");
{
alert('You must complete the Header field');
return false
}
}
</script>
</head>
...
<form action=\"AddInformation1.asp?Subcategory=<%= Request.QueryString(\"Subcategory\")
?>
\" method=\"post\" name=\"AddForm\" onSubmit=\"return isFilledHeader()\">
Web Training
Header
?>
Free Math Test
Fun Math Games
John Pollock posted this at 21:22 — 7th December 2001.
He has: 628 posts
Joined: Mar 1999
Oh, wait, I missed this before. Take the semicolon off of this line:
if(document.AddForm.Header.value == "");
It doesn't need it since it is introducing a conditional.
Java Script: A Beginner's Guide
Page Resource
artsapimp posted this at 22:06 — 7th December 2001.
They have: 330 posts
Joined: Apr 2000
Perfect, thank you.