homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Can anyone see what id wrong with this simple script?

5+ Year Member

Msg#: 3426184 posted 6:11 pm on Aug 19, 2007 (gmt 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>




WebmasterWorld Senior Member 10+ Year Member

Msg#: 3426184 posted 9:28 am on Aug 20, 2007 (gmt 0)

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. ;)


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved