SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Oct 2005
    Posts
    255
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Validate list menu in form

    Hi,
    Ive got a form which i validate using javascript. One of the form elements is a list menu.

    I use the following script to validate that the form fields have been filled in:

    PHP Code:
    function verifyBook() {
    var 
    themessage "You are required to complete the following fields: ";
    if (
    document.calypsoBook.phone.value=="") {
    themessage themessage " -  Phone";
    }
    if (
    document.calypsoBook.style.value=="") {
    themessage themessage " -  Fishing Style";
    }
    //alert if fields are empty and cancel form submit
    if (themessage == "You are required to complete the following fields: ") {
    document.calypsoBook.submit();
    }
    else {
    alert(themessage);
    return 
    false;
       }

    The problem is, document.calypsoBook.style.value refers to a list menu, and even when i have selected an item, it still gives the alert. i think there must be a different way to validate that something has been selected from the list menu.

    Please help. ive googled but not found anything.

  2. #2
    SitePoint Addict
    Join Date
    Oct 2005
    Posts
    255
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dont worry, i found something. Turns out they are more commonly referred to as drop down menus which is why i couldnt find anything. dreamweaver calls them list menus.

    http://www.elated.com/articles/form-...th-javascript/


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
  •