Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] newbie function question


  • From: javascript@xxxxxxxxxx (Matthew Collins)
  • Subject: [Javascript] newbie function question
  • Date: Thu, 15 Aug 2002 09:11:05 -0400

hi all,

i'm trying to write a function to validate a form.  problem is, i want the
function to be reusable on many pages, so one of the variables passed to the
function is the form name, while the other variable is the name of the
fields to be checked.

problem is, i'm getting an error that the "'document.FormName.formArray'
does not exist"

here's the javascript:

<script language="JavaScript">

<!--
function IsFormComplete(FormName,formFields)
{
var x       = 0
var formArray = formFields.split(",");

for (x=0; x < formArray.length; x++)
   {
	if (document.FormName.formArray[x].value == '')
     {
        alert('Please enter the '+document.FormName.formArray[x].name +' and
try again.')
        document.FormName.formArray[x].focus()
     }
   }
}
// -->

</script>

*and the html of the form*
<form method="POST" action="formTest.asp" name="form"
onsubmit="IsFormComplete('form','T1,S1,C1');">


thanks in advance,