Validate Menu List in form.


i wondering if there way validate menu or list in form. ie. @ http://www.metrobham.org/register.html @ least make "choose one" menu/list required field "age" , "gender" fields.

 

thanks

you can , javascript before information sent php processing script. i've validated 'choose one' select, 'gender' radio buttons , 'age' select. can rest if want have @ code , see how works. it's not difficult when see pattern forming.

 

 

<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd">

<html>

<head>

<meta http-equiv="content-type" content="text/html; charset=utf-8">

<title>untitled document</title>

<!-- validate form  -->

<script type="text/javascript">

<!--

function validateform() {

var choose = document.forms.form1.choose.value;

// inform customer provide requirements

if (choose == null || choose == "" || choose == "please choose")

{

alert("please choose list provided");

return false;

}

var age = document.forms.form1.age.value;

// inform customer provide age

if (age == null || age == "" || age == "select age")

{

alert("please select age");

return false;

}

 

// inform customer provide gender

if(document.getelementbyid('gender_0').checked) {

} else if(document.getelementbyid('gender_1').checked) {

} else {

  alert ("you must select gender");

  return false;

}

} // end function

-->

</script>

</head>

 

<body>

<form id="form1" name="form1" method="post" action="registration.php" onsubmit="return validateform()">

    <table width="100%" border="0" cellpadding="0" cellspacing="0">

      <tr>

        <td width="27%" align="right"><label for="choose">choose one:</label></td>

        <td width="73%" align="left"><select name="choose" id="choose">

          <option value="please choose" selected="selected">please choose</option>

          <option value="baptism">baptism</option>

          <option value="baby dedication">baby dedication</option>

          <option value="new member">new member</option>

        </select></td>

      </tr>

      <tr>

        <td align="right"><label for="name2">name:</label></td>

        <td align="left"><input name="name" type="text" id="name2" size="40" /></td>

      </tr>

      <tr>

        <td align="right"><label for="address">address:</label></td>

        <td align="left"><input name="address" type="text" id="address" size="45" /></td>

      </tr>

      <tr>

        <td align="right"><label for="city">city:</label></td>

        <td align="left"><input name="city" type="text" id="city" size="35" /></td>

      </tr>

      <tr>

        <td align="right"><label for="state">state:</label></td>

        <td align="left"><input name="state" type="text" id="state" size="25" /></td>

      </tr>

      <tr>

        <td align="right"><label for="zip">zip:</label></td>

        <td align="left"><input name="zip" type="text" id="zip" size="5" /></td>

      </tr>

      <tr>

        <td align="right"><label for="phone">phone:</label></td>

        <td align="left"><input name="phone" type="text" id="phone" size="12" /></td>

      </tr>

      <tr>

        <td align="right"><label for="email">email:</label></td>

        <td align="left"><input name="email" type="text" id="email" size="50" /></td>

      </tr>

      <tr>

        <td align="right"><label for="age">age (if child):</label></td>

        <td align="left"><select name="age" id="age">

          <option value="select age" selected="selected">select age</option>

          <option value="1">1</option>

          <option value="2">2</option>

          <option value="3">3</option>

          <option value="4">4</option>

          <option value="5">5</option>

          <option value="6">6</option>

          <option value="7">7</option>

          <option value="8">8</option>

          <option value="9">9</option>

          <option value="10">10</option>

          <option value="11">11</option>

          <option value="12">12</option>

          <option value="13">13</option>

          <option value="14">14</option>

          <option value="15">15</option>

          <option value="16">16</option>

          <option value="17">17</option>

          <option value="18">18</option>

          <option value="19">19</option>

        </select></td>

      </tr>

      <tr>

        <td align="right">gender:</td>

        <td align="left"><p>

          <label>

            <input type="radio" name="gender" value="male" id="gender_0" />

            male</label>

          <br />

          <label>

            <input type="radio" name="gender" value="female" id="gender_1" />

            female</label>

          <br />

        </p></td>

      </tr>

      <tr>

        <td align="right"><label for="comments">comments:</label></td>

        <td align="left"><textarea name="comments" id="comments" cols="45" rows="5"></textarea></td>

      </tr>

      <tr>

        <td align="right"><input type="reset" name="clear" id="clear" value="reset form!" /></td>

        <td align="left"><input name="submit" type="submit" id="submit" onclick="mm_validateform('name2','','r','address','','r','city','','r','state','','r','zi p','','r','phone','','risnum','email','','risemail');return document.mm_returnvalue" value="submit" /></td>

      </tr>

    </table>

  </form>

</body>

</html>



More discussions in Dreamweaver support forum


adobe

Comments

Popular posts from this blog

How to set the order of FAQs instead of alphabetical

Thread: Get UK Keyboard working

how do I change the e-mail address for my merchant account