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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can Javascript be used to validate a dynamically created form

Status
Not open for further replies.

SilentCobra

Programmer
Jan 24, 2001
4
0
0
US
I have several forms that are dynamically generated from elements selected from a table. Each element name is dynamically made from the unique ID field of each piece of content in the table. I already have a function that validates form fields but the names are standard and static.


How would I be able to validate the required fields in a javascript function without first knowing the name of the field?
 
Loop through the form elements by index. If you have types of elements you want to ignore, you can do that, too.

for (var fi=0;fi<document.formname.elements.length;fi++)
{
with(document.formname.elements[fi])
{
if (type=='text')
{
//your code here
}
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top