JavaScript lesson 4 extra credit part 2

Work with the other form entites: drop downs, radio buttons, check boxes and pick lists, along with other events handlers like onFocus, onSubmit, onChange.



Your name:
E-mail:
Choose your country:
 

Source:

<head>
<script language="javascript" type="text/javascript">
<!--
function validName(yourName){
 if (yourName == ("" || "Donald Duck")){
 return false
 }
 else{
 return true
 }  
 }
function validEmail(yourEmail){
 if(yourEmail == ""){
 return false
 }
 else{
 return true
 }
 }
function validCountry(yourCountry){
 if(yourCountry == ""){
 return false
 }
 else{
 return true
 }
 }
function submitForm(nameForm){
 if (validName(nameForm.yourName.value) && validEmail(nameForm.yourEmail.value) &&  validCountry(nameForm.yourCountry.value)){
 window.location="thank_you.html"
 return true
 }
 else{
 alert("Please fill in the form!")
 return false
 }
 }
//-->
</script>
</head>

 <body>
 <form onsubmit="return submitForm(this)" method="post" name="jansForm" action=
  "mailto:jan.nylund@bredband.net" enctype="text/plain" id="jansForm">
   <table frame="box" rules="none" cellpadding="10">
    <tr>
     <td>
      Your name:
     </td>
     <td>
      <input type="text" name="yourName" size="50">
     </td>
    </tr>
    <tr>
     <td>
      E-mail:
     </td>
     <td>
      <input type="text" name="yourEmail" size="50">
     </td>
    </tr>
    <tr>
     <td>
      Choose your country:
     </td>
     <td>
      <select name="yourCountry">
       <option value="usa">
        USA
       </option>
       <option value="sweden">
        Sweden
       </option>
       <option value="germany">
        Germany
       </option>
       <option value="england">
        England
       </option>
       <option value="scotland">
        Scotland
       </option>
       <option value="wales">
        Wales
       </option>
       <option value="norway">
        Norway
       </option>
       <option value="denmark">
        Denmark
       </option>
       <option value="france">
        France
       </option>
       <option value="spain">
        Spain
       </option>
       <option value="other">
        Other
       </option>
       <option value="" selected>
        Country?
       </option>
      </select>
     </td>
    </tr>
    <tr>
     <td colspan="2">
      <input type="submit" value="Submit">  <input type="reset" value="Reset" name="reset"
      onclick="return confirm('Are you sure!')">
     </td>
    </tr>
   </table>
  </form>
</body>