For JavaScript, here is the easiest way to do this is for your case: Use a hidden variable to store the number of packages.
For each package, I am guessing you have 3 fields: height, weight, and length. The names for these fields should be something to the effect of: height_1, weight_1, length_1 (for package 1), height_2, weight_2, length_2 (for package 2), etc. Then you would simply iterate through the total number of packages and test each field to make sure it is a number. Something like this: var total=document.form_name.total_packages.value; for(var i=1; i=<total; i++) { var thisHeight = eval('document.form_name.height_' + i + '.value'); var thisWeight = eval('document.form_name.weight_' + i + '.value'); var thisLength = eval('document.form_name.length_' + i + '.value'); if(!thisHeight.match(/^\d+$/)) { // height contains non-numeric characters. Take some action } if(!thisWeight.match(/^\d+$/)) { // weight contains non-numeric characters. Take some action } if(!thisLength.match(/^\d+$/)) { // length contains non-numeric characters. Take some action } } Of course, this is just an example and you would need to make the code work for your specifics. Andy Miller IS Designer Butte College 530.895.2946 -----Original Message----- From: Rizwan Merchant [mailto:[EMAIL PROTECTED] Sent: Sunday, May 28, 2006 3:52 PM To: Struts Users Mailing List Subject: Validating struts elements of array type in javascript Hi, I have a Order form that contains an Order object. One of the properties of the order object is an array called "packages". Each package has a height, weight and length. In the jsp, we create as many rows as there are packages in the order and the customer can define the dimensions of each package. I would like to validate the values entered for each of the packages..how would i do this in javascript? Basically, is there a way to get a handle on each of the packages in javascript and loop through them to check their types? We are using the commons validator for the rest of the validation. not sure if i can use that for this purpose. Thanks, -Riz. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]