I am in a JavaScript class, and we have to get all of our code to validate at the w3c website... Here is my code, it does what I want it to do which is require the user to enter the name and either the address of the email address, but when I try to validate it through w3c, I get the following errors... Can anyone help?
Here are the errors...
Validation Output: 2 Errors
1. Warning Line 26, Column 47: character "&" is the first character of a delimiter but occurred as data.
else if (document.form1 .address.value == "" && document.form1. email.value == "")
This message may appear in several cases:
* You tried to include the "<" character in your page: you should escape it as "<"
* You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&", which is always safe.
* Another possibility is that you forgot to close quotes in a previous tag.
2. Warning Line 26, Column 48: character "&" is the first character of a delimiter but occurred as data.
else if (document.form1 .address.value == "" && document.form1. email.value == "")
This message may appear in several cases:
* You tried to include the "<" character in your page: you should escape it as "<"
* You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&", which is always safe.
* Another possibility is that you forgot to close quotes in a previous tag.
3. Error Line 26, Column 48: XML Parsing Error: xmlParseEntityR ef: no name.
else if (document.form1 .address.value == "" && document.form1. email.value == "")
4. Error Line 26, Column 49: XML Parsing Error: xmlParseEntityR ef: no name.
else if (document.form1 .address.value == "" && document.form1. email.value == "")
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Customer Login Screen</title>
<style type="text/css">
<!--
.style1 {
font-size: 24px;
font-weight: bold;
}
body {
background-color: #C69C98;
}
-->
</style>
<script type="text/JavaScript">
function submitForm()
{
if (document.form1.name.value == "")
{
window.alert("You must enter your name!");
return false;
}
else if (document.form1.address.value == "" && document.form1.email.value == "")
{
window.alert("Please enter either your mailing address or your email address.");
return false;
}
else
window.open('SRTY.html');
return true;
}
</script>
</head>
<body>
<p class="style1"><img src="Kudler-food-blk.gif" alt="Logo" width="275" height="146" /> </p>
<p class="style1">Join Our Mailing List!! </p>
<table width="358" border="0">
<tr>
<td width="9"> </td>
<td width="312"> </td>
<td width="23"> </td>
</tr>
<tr>
<td> </td>
<td>
<form id="form1" name="form1" method="post" action="">
<p>Customer Name:
<input type="text" name="name"/>
</p>
<p>Mailing Address:
<input type="text" name="address"/>
</p>
<p>Email Address:
<input type="text" name="email"/>
</p>
<p>Telephone Number:
<input type="text" name="phone"/>
</p>
<p align="left"> </p>
<p align="left">
<input type="submit" value="Submit" onclick="return submitForm();"/>
<input type="reset"/>
</p>
</form></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<p><a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-xhtml10-blue"
alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a></p>
</body>
</html>
Here are the errors...
Validation Output: 2 Errors
1. Warning Line 26, Column 47: character "&" is the first character of a delimiter but occurred as data.
else if (document.form1 .address.value == "" && document.form1. email.value == "")
This message may appear in several cases:
* You tried to include the "<" character in your page: you should escape it as "<"
* You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&", which is always safe.
* Another possibility is that you forgot to close quotes in a previous tag.
2. Warning Line 26, Column 48: character "&" is the first character of a delimiter but occurred as data.
else if (document.form1 .address.value == "" && document.form1. email.value == "")
This message may appear in several cases:
* You tried to include the "<" character in your page: you should escape it as "<"
* You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&", which is always safe.
* Another possibility is that you forgot to close quotes in a previous tag.
3. Error Line 26, Column 48: XML Parsing Error: xmlParseEntityR ef: no name.
else if (document.form1 .address.value == "" && document.form1. email.value == "")
4. Error Line 26, Column 49: XML Parsing Error: xmlParseEntityR ef: no name.
else if (document.form1 .address.value == "" && document.form1. email.value == "")
Comment