/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] document.form.name is null or not an object

I want to make certain fields required in my form but i keep getting the error document.form.name is null or not an object but i copied and pasted the code from a website this is my code

[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>
<SCRIPT LANGUAGE=”JavaScript”>
<!– Original: Wayne Nolting ([email protected]) –>

<!– This script and many more are available free online at –>
<!– The JavaScript Source!! [url]http://javascript.internet.com[/url] –>

<!– Begin
function verify() {
var themessage = “You are required to complete the following fields: “;
if (document.form.name.value==””) {
themessage = themessage + ” – First Name”;
}
if (document.form.surname.value==””) {
themessage = themessage + ” – Last Name”;
}
if (document.form.email.value==””) {
themessage = themessage + ” – E-mail”;
}
if (document.form.contact.value==””) {
themessage = themessage + ” – contact”;
}

//alert if fields are empty and cancel form submit
if (themessage == “You are required to complete the following fields: “) {
document.form.submit();
}
else {
alert(themessage);
return false;
}
}
// End –>
</script>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Untitled Document</title>

</head>

<body>
<form action=”mailto:[email protected]” method=”post” enctype=”text/plain”>
<p><br />
</p>
<table width=”200″ border=”0″>
<tr>
<td width=”141″>Name : </td>
<td width=”172″><input name=”name” type=”text” /></td>
</tr>
<tr>
<td>Surname:</td>
<td><input type=”text” name=”surname” /></td>
</tr>
<tr>
<td>Contact:</td>
<td><input type=”text” name=”contact” /></td>
</tr>
<tr>
<td>Email</td>
<td><input type=”text” name=”email” /></td>
</tr>
<tr>
<td>Product</td>
<td><select name=”product”>
<option> – please select from the list – </option>
<option>ARGUS Valuation – DCF</option>
<option>ARGUS Valuation Lite</option>

<option>ARGUS Asset Management</option>

<option>ARGUS Property Budget</option>

<option>ARGUS Developer</option>

<option>ARGUS Development Budget</option>

<option>Sage Timbeline Office</option>
</select>
</td>
</tr>
<tr>
<td>Version</td>
<td><select name=”version”>
</select></td>
</tr>
<tr>
<td>Issue Type </td>
<td><select name=”issue”>
</select></td>
</tr>
<tr>
<td>Any Comments </td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan=”2″><textarea name=”textarea” cols=”50″ rows=”5″></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><div align=”right”>
<input type=”reset” name=”reset” value=”Reset” />
</div></td>
<td> <input type=button value=”Submit Request” onclick=”verify();”></td>

</tr>
</table>
</form>
<p><center>
<font face=”arial, helvetica” size”-2″>Free JavaScripts provided<br>
by <a href=”http://javascriptsource.com”>The JavaScript Source</a></font>
</center><p>

<!– Script Size: 1.64 KB –>
</body>
</html>
[/code]

Anybody that can help me please??

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KorJun 17.2008 — You forgot to give your form a [COLOR="Blue"]name[/COLOR].

If your reference is:
<i>
</i>document.[COLOR="Blue"]form[/COLOR].[COLOR="DarkGreen"]contact[/COLOR]

That means your form's name must be [COLOR="Blue"]form[/COLOR]
<i>
</i>&lt;form [COLOR="Blue"]name="form"[/COLOR] action="mailto:[email protected]" method="post" enctype="text/plain"&gt;


The syntax variants are

document.[COLOR="Blue"]formname[/COLOR].[COLOR="DarkGreen"]elementname[/COLOR]

or

document.forms['[COLOR="Blue"]formname[/COLOR]'].elements['[COLOR="DarkGreen"]elementname[/COLOR]']

or even

document['[COLOR="Blue"]formname[/COLOR]']['[COLOR="DarkGreen"]elementname[/COLOR]'] (if you have no other image, link, anchor of frame/iframe with the same name)
Copy linkTweet thisAlerts:
@cherylleeauthorJun 17.2008 — THANKS hehe so happy!!!
×

Success!

Help @cheryllee spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...