Hello,

I have create some JS form validation for some forms as follows:

HTML Code:
		<script language="javascript">

		function app4formCheck() {	
			var alertMessage = "Please provide the following information in the appropriate fields:\n";
		
			if (window.document.app4form.surname_f.value == "") {var surname_text = "Your Surname\n";}
			if (window.document.app4form.surname_f.value == "") {alertMessage = alertMessage + surname_text;}
		
			if (window.document.app4form.surname_f.value == "") {
			alert(alertMessage);
			return false;
			}
		}
		
		</script>
It all worked well.

For some valid reasons I needed to change the names of the fields declared in the form to arrays. The reason I did this was to accomodate multiple sets of applicant records (i.e. 3 different customer records) being modified in the same form.

For this reason I was advised by a friend to define the field names as arrays and storing the information in my db using a simple function. It works great!

Below is how I've defined field names in the form:
HTML Code:
<textarea name="passportData[<?PHP echo $rec_id ?>][surname]" rows="11" cols="94">
The field name passportData contains the record id [$rec_id] and the database field name is [surname]. The problem is that when I use this new naming convention using an array, the Javascript does not work. Below is how I modified the JS validation:

HTML Code:
		<script language="javascript">
function app4formCheck() {	
			var alertMessage = "Please provide the following information in the appropriate fields:\n";
		
			if (window.document.app4form.passportData[<?PHP echo $_GET['rec_id'] ?>][surname].value == "") {var surname_text = "Your Surname\n";}
			if (window.document.app4form.passportData[<?PHP echo $_GET['rec_id'] ?>][surname].value == "") {alertMessage = alertMessage + surname_text;}
		
			if (window.document.app4form.passportData[<?PHP echo $_GET['rec_id'] ?>][surname].value == "") {
			alert(alertMessage);
			return false;
			}
		}	
		</script>
The PHP is putting the correct information in the javascript as follows:

HTML Code:
		<script language="javascript">

		function app4formCheck() {	
			var alertMessage = "Please provide the following information in the appropriate fields:\n";
		
			if (window.document.app4form.passportData[161][surname].value == "") {var surname_text = "Your Surname\n";}
			if (window.document.app4form.passportData[161][surname].value == "") {alertMessage = alertMessage + surname_text;}
		
			if (window.document.app4form.passportData[161][surname].value == "") {
			alert(alertMessage);
			return false;
			}
		}
		
		</script>
Does anyone know why when the field is left empty it does not pop up the alert window? What I need is a way of making the JS recognize the array based fields as empty and putting up the alert when the JS test is run. All help is greatly appreciated.

Thanks in advance,

Mario