jdelgado
June 3rd, 2005, 12:23 PM
I'm having a little trouble with some code. Here is the background...
I created a dynamic html form so that a user can enter a number, and then that many fields will be created in the form.
The first page says "please enter a number of entries: ", user enters, say 3. Automatically, 3 sections are created with form fields for 3 people. This is all well and good, until I try to perform form validation. I have a good idea as to how to do it in php, but Im looking for a similar javascript solution. The part of code giving me trouble looks something like this:
for(var i = 0; i < numentries; i++){
var fname = document.form.('FirstName'+i).value);
if(fname.length<1)
errormessage += "\nThe First Name field is required"; }
}
obviously this code is incorrect, but I think you can tell what i am trying to do and hopefully someone out there can offer some insight. Thanks in advance!
J
I created a dynamic html form so that a user can enter a number, and then that many fields will be created in the form.
The first page says "please enter a number of entries: ", user enters, say 3. Automatically, 3 sections are created with form fields for 3 people. This is all well and good, until I try to perform form validation. I have a good idea as to how to do it in php, but Im looking for a similar javascript solution. The part of code giving me trouble looks something like this:
for(var i = 0; i < numentries; i++){
var fname = document.form.('FirstName'+i).value);
if(fname.length<1)
errormessage += "\nThe First Name field is required"; }
}
obviously this code is incorrect, but I think you can tell what i am trying to do and hopefully someone out there can offer some insight. Thanks in advance!
J