array validation

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
CrazyJimmy
Forum Commoner
Posts: 34
Joined: Tue Nov 19, 2002 1:40 pm

array validation

Post by CrazyJimmy »

Hello,

I have a array on my from called name[] which I then pass to a php script. I would like validate this for null values in javascript but cant get it figured out or even know if its possible.

Thanks
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

This should work:

Code: Select all

<script language=javascript>
bla=new Array(12,5,0,234,0,2365,0); //just some sample values
for (i=0;i<bla.length;i++)
	&#123;
	if (!bla&#1111;i])   //that's the line you want
		alert ("Array Index "+i+" empty");
	&#125;
</script>
Post Reply