59 users online (1 members and 58 guests)  


  Results 1 to 2 of 2

Related

  1. Drop Down menu Validation change mind?    Forum: Javascript Forum
    Replies: 1
  2. Replies: 2
  3. Jump Menu covers drop down menu    Forum: HTML Forum
    Replies: 1
  4. Drop down menu    Forum: HTML Forum
    Replies: 6
  5. Replies: 6
  1. #1
    Roses89's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2010
    Posts
    1

    Help!!Drop Down Menu Validation!URGENT!

    Hey guys,I needed quick and urgent help on this.
    Im basically having LOADS of trouble with validating drop down menus.Now the thing is this, Im making a form with more than one drop down menu,I need a function such that would validate the drop down menus and make sure that they're not equal to NULL.I basically dont want the form submitted till the user has selected a valid option.The following is just my attempt to try and validate one drop down menu, which was unsuccessful.I need a function that would validate more than one drop down menu. Any ideas?Please help me!I need it done by tomorrow:S

    Heres my code btw


    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

    <head>
    <meta http-equiv="Content-Script-Type" content="text/javascript"/>
    <script type="text/javascript" src = "job.js"></script>

    <script type="text/javascript">
    <!--


    //function for mandatory

    function valDrop(jobKnw)
    {
    if (jobKnw == '')
    {
    return false;
    }
    else return true;
    }

    // -->

    </script>
    <title>Rate Form</title>

    </head>


    <body>
    <p>
    <img class="pos" src="banner1.jpg" alt="banner"/>
    </p>

    <h1>
    Rating Information Form
    </h1>

    <form name="form" method="post" action="URL" onSubmit="return valDrop();">


    <fieldset>
    <legend><i>Review Ratings</i></legend>

    <p>Please rate the employees on a scale of 1-5, where 1 is Excellent and 5 is Poor.</p>


    <p class="man">(The feilds marked with * are mandatory)</p>

    <table border="0">
    <tr>
    <td>

    <select name="jobKnw" size="1" id="jobKnw">
    <option value="Pc"> </option>
    <option value="one"> 1 </option>
    <option value="two"> 2 </option>
    <option value="three"> 3 </option>
    <option value="four"> 4 </option>
    <option value="five"> 5 </option>
    </select>

    </td>
    </tr>
    </table>

    <p>
    <input type="submit" value="Finished Survey" />
    <input type="reset" value="Reset"/>
    </p>

    </fieldset>
    </form>
    </body>
    </html>

  2. #2
    coothead's Avatar
    bald headed old fart

    Status
    Offline
    Join Date
    Aug 2003
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    732

    Re: Help!!Drop Down Menu Validation!URGENT!

    Hi there Roses89,

    and a warm welcome to these forums.

    Bearing in mind that form validation, to be truly reliable,
    needs to be done server-side here is a client-side example...
    Code:
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="language" content="english"> 
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    
    <title></title>
    
    <script type="text/javascript">
    
    function init(){
       df=document.forms[0];
    df.onsubmit=function() {
       return valDrop();
      }
     }
    
    function valDrop(){
       sel=df.getElementsByTagName('select');
    for(c=0;c<sel.length;c++) {
    if(sel[c].value=='') {
       return false;
       }
      }
     }
    
    if(window.addEventListener){
       window.addEventListener('load',init,false);
     }
    else { 
    if(window.attachEvent){
       window.attachEvent('onload',init);
      }
     }
    
    </script>
    
    </head>
    <body>
    
    <form action="http://www.google.com">
    
    <div>
    <select name="jobKnw" size="1">
     <option value="">option 1</option>
     <option value="one">1</option>
     <option value="two">2</option>
     <option value="three">3</option>
     <option value="four">4</option>
     <option value="five">5</option>
    </select>
    
    <select name="anotherJobKnw" size="1">
     <option value="">option 2</option>
     <option value="six">6</option>
     <option value="seven">7</option>
     <option value="eight">8</option>
     <option value="nine">9</option>
     <option value="ten">10</option>
    </select>
    
    <select name="andAnotherJobKnw" size="1">
     <option value="">option 3</option>
     <option value="eleven">11</option>
     <option value="twelve">12</option>
     <option value="thirteen">13</option>
     <option value="fourteen">14</option>
     <option value="fithteen">15</option>
    </select>
    
    </div><div>
    
    <input type="submit" value="Finished Survey">
    <input type="reset" value="Reset">
    
    </div>
    
    </form>
    
    </body>
    </html>
    



Tags for this Thread