With clause syntax errors but how do I fix it?

Giganews Newsgroups
Subject: With clause syntax errors but how do I fix it?
Posted by:  Phil Powell (soazi…@erols.com)
Date: Mon, 1 Sep 2003

<script>
<!--

  function isValidAlert() {
  for (var i = 0; i < document.alertForm.length; i++) {
    with (document.alertForm.elements[i]) {
    if (.name == "text" || .name == "password" || .name == "textarea") {
      if (.value == "") {
      alert("Please enter a " + .name);
      focus();
      return false;
      }
    } else if (.name == "select-one") {
      if (.options[document.alertForm.elements[i].selectedIndex].value ==
"") {
      alert("Please select a " + .name);
      return false;
      }
    }
    }
  }
  }

//-->
</script>

I don't know the answer to this problem, I am getting syntax errors, and
"with" does not search well on any Javascript tutorial.  So this is my only
option for help; can someone tell me what I did wrong?

Thanx
Phil

Replies