Discussion Locked

Multiple forms in JavaScript

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,

I am new to Web Development. Currently I am working on a webpage that has multiple forms (start date calendar, end date calendar, checkboxes, etc) and I need to validate the fields to make sure that the user has entered all of the required fields. The only way that I have seen to do form validation involves putting a form around almost all of the code. I have been told that you cannot nest forms. Can anyone offer me any suggestions on how to tackle such a taske? I would appreciate any assistance that you could give me. Thanks in advance!!

5 replies

by clehnert

You might want to think about accessing the forms collection. It is a collection which Javascript can access of all forms on your web page. You can access them through an index or the forms name. You can then do validation checks depending the form.

Check out msdn.microsoft.com

by ebob

...

Then up in your validation schemes you can refer to the form explicitly by name:

document.form1.field

etc.

by caractacus

Are you sure you want multiple forms? You can only post one form to the server.

You may have reasons for this, but I think it more likely that you are looking for multiple groups of controls within a single form.

The controls in each section would be named uniquely of course, and validation would occur as usual on the form's validate event.

I hope this is useful.

by nise_k

Hi friend,

The suggestion u got about putting form all the codes under form tags is correct and is followed by most.

You can then access the elements' value through -
frames[i].document.forms[j].elements[i].value

Regards,
Nise.

by nise_k

Hi friend,

The suggestion u got about putting form all the codes under form tags is correct and is followed by most.

You can then access the elements' value through -
frames[i].document.forms[j].elements[i].value

Regards,
Nise.

This discussion is closed to new replies.