SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  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 Validating Combo Boxes using JS

    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
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Try document.formname.dropdownName.selectedIndex. It will return a number between 0 and (amount of options -1), 0 being your first option listed.

  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 worked, thanks!


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
  •