I am attempting to convert a HTML form to XHTML. I am having problems with the validation script, which worked in the old form but not in the new one. The script makes sure that all the boxes are filled out before submitting.
I have both <input> and <textarea> elements. The script recognizes a blank <input> but not the blank <textarea>.
What's wrong?
Javascript snippets:
<script type="text/javascript">
function verify()
{
if(document.forms['formname'].aname1.value=="")
{
alert("Please enter your name");
document.forms['formname'].aname1.focus();
return false;
}
[snip]
if(document.forms['formname'].gaddress.value=="")
{
alert("Please enter your mailing address");
document.forms['formname'].gaddress.focus();
return false;
}
[snip]
else
return true;
}
The code below is your code with the [snip]s removed and your validation script prompts for both the name and email address if they are missing - but with your current code logic, only 1 at a time if both are missing.
The only thing I would normally do, but haven't done in your case, is put the opening and closing textarea tags on the one line.
Your code works fine in my IE8 and FF3.6
Maybe there is something else going on in your code that you haven't posted that is causing your problem.
Now I am really puzzled. As you entered the code it does work. But in my original the same code skips the textarea. I'll dig deeper to see if I can figure out where the error is.
Thanks.
I recreated a new page from scratch. Now it works. The code appears to be identical on both pages, One works, and one doesn't. Go figure.
Thanks for your help.
Bookmarks