Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loops and form validation

Status
Not open for further replies.

niceguythom

Programmer
Mar 27, 2001
3
US
I have a table with 50 rows, each row created with a For X = 1 to 50 loop naming each row Column1x and Column2x. I need to validate the data and I don't want to have 50 If--Then's. I can't seem to get a For-Next working with JavaScript where I "tack on" the X to the end of the object form.textarea.value and run through the 50 rows. (I know what I'm trying to say, I just don't know if I'm saying it...) If you can figure out what I'm trying to ask and know how to fix it, HELP!!!
 
Hi,

Could you post the code you used?
That will clarify what your aim is.

Tnx,

Kristof -------------------
Check out my new site:

Any suggestions are more than welcome.
There's a LOT of work to do, so judge fairly. :)
 
I am assuming that you have 50 rows of input fields. Lets say you have one field that is called field1x, where x is between 1 and fifty. You Javascript loop would then be something like:

for (i = 1; i <= 50; i++) {

if (eval(&quot;document.myForm.field1&quot; + i).value == &quot;&quot;) {
alert(&quot;You must enter a value in field1 in row &quot; + i);
}

// Validate all other fields in the same way
}

Hope this helps a little. If not, post your code as Kristoff suggests. Mise Le Meas,

Mighty :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top