Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Can anyone see what id wrong with this simple script?

6:11 pm on Aug 19, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 4, 2006
votes: 0

I'm innocently putting together a validation script but then I get this error: error_name has no properties - in the .style line...

<script language="javascript" type="text/javascript">
var error_name = document.getElementById('error_name');
error_name.style.position = 'static';
<p class='error' id='error_name'>Please enter you name.</p>
<p class='error' id='error_email'>Please enter a valid email address.</p>
<p class='error' id='error_remail'>Your email addresses do not match. Please reenter them.</p>
<p class='error' id='error_subject'>You did not enter a subject.</p>
<p class='error' id='error_message'>Tou did not enter a message.</p>


9:28 am on Aug 20, 2007 (gmt 0)

Senior Member from GB 

WebmasterWorld Senior Member 10+ Year Member

joined:Oct 2, 2003
votes: 30

Hi there horseatingweeds,

the div with the id - error_name does not exist until the page is loaded.
You need to allow for this in your script...

<script type="text/javascript">
var error_name=document.getElementById('error_name');

Also note that language=javascript is deprecated and should not be used. ;)



Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members