469,327 Members | 1,259 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

i'm told document.almostdone.names has no properties?

Markus
6,050 Expert 4TB
I'm writing something that loops through a form to check if any fields are empty. I got to this:
Expand|Select|Wrap|Line Numbers
  1. function checkEmptyFields()
  2. {
  3.     names = new Array("first_name", "last_name", "country", "city", "dob_d");
  4.     for (i = 0; i < names.length; i++)
  5.     {
  6.         el = document.almostdone.names[i].value;
  7.         if(el.empty())
  8.         {
  9.             alert(el + " was empty");
  10.         }
  11.     }
  12. }
  13.  
But i keep being told
Expand|Select|Wrap|Line Numbers
  1. document.almostdone.names has no properties
  2. http://localhost/blog.mahcuz.com/signup/almostdone/js/validateSignUp.js
  3. Line 6
  4.  
  5. line 6: el = document.almostdone.names[0].value;
almostdone is the name of the form.

Not quite sure _
Feb 21 '08 #1
1 840
acoder
16,027 Expert Mod 8TB
The form doesn't have a names array. What you need to use is the elements array, e.g. document.forms["almostdone"].elements[names[i]].value.
Feb 22 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

12 posts views Thread by Kepler | last post: by
6 posts views Thread by skubik | last post: by
2 posts views Thread by Robert Oschler | last post: by
3 posts views Thread by throwaway_addr_12345 | last post: by
5 posts views Thread by Martin Rinehart | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.