topical media & game development

talk show tell print

basic-javascript-10-ch10-q2.htm / htm

  <script language="JavaScript">
  function checkForm(theForm)
     var formValid = true;
     var elementCount  = 0;
     while(elementCount < theForm.length)
        if (theForm.elements[elementCount].type == "text")
           if (theForm.elements[elementCount].value == "")
              alert("Please complete all form elements")
              formValid = false;
     return formValid;
  <form name="form1" onsubmit="return checkForm(document.form1)">
     <input type="text" id="text1" name="text1">
     CheckBox 1<input type="checkbox" id="checkbox2" name="checkbox2">
     CheckBox 1<input type="checkbox" id="checkbox1" name="checkbox1">
     <input type="text" id="text2" name="text2">
     <input type="submit" value="Submit" id="submit1" name="submit1">

(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.