SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot frosco's Avatar
    Join Date
    Jul 2003
    Location
    WA state
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Combo Box Validation

    I posted this in the Newbie section, but I think that may have been the wrong place to post.

    Not a clue what I'm doing. This is part of some javascript someone wrote for me. It was originally designed to validate a text box, but I've changed it to a combo box and now, no matter what I do, it won't accept anything in the combo box.

    <----------------------CODE CHUNK---------------------->

    if(document.guestbook.GRAD.value.length <2)
    {
    ++i;
    msg += 'You must supply your graduation year\n';
    document.guestbook.GRAD.style.background=errcolour;
    document.guestbook.GRAD.style.color='#FFFFFF';
    }else{
    document.guestbook.GRAD.style.background='#FFFFFF';
    document.guestbook.GRAD.style.color='';
    }

    <-----------------------END CHUNK---------------------->

    I've also tried

    if(document.guestbook.GRAD.value == '')

    and that didn't work either.
    Thanks!

  2. #2
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    What do you mean by combo box? In other words, would you mind posting some html?

    if you mean a selection list, you need to follow the DOM -- document.formname.selectName.options[document.formname.selectName.selectedIndex].value

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  3. #3
    SitePoint Zealot frosco's Avatar
    Join Date
    Jul 2003
    Location
    WA state
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That did the trick, thanks!

  4. #4
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no prob
    Where the World Once Stood
    the blades of grass
    cut me still


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •