General discussion

Locked

Multiple forms in JavaScript

By isugirl80 ·
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!!

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Forms Collection

by clehnert In reply to Multiple forms in JavaScr ...

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

Collapse -

Or NAME your forms

by eBob In reply to Forms Collection

<form name="form1" ...>
...
</form>
...
<form name="form2" ...>
...
</form>

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

document.form1.field

etc.

Collapse -

Are you sure you want multiple forms?

by Caractacus In reply to Forms Collection

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.

<form>

<fieldset><legend>Start Date</legend>
...
</fieldset>

<fieldset><legend>End Date</legend>
...
</fieldset>

</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.

Collapse -

forms array

by nise_k In reply to Multiple forms in JavaScr ...

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.document.forms[j].elements.value

Regards,
Nise.

Collapse -

forms array

by nise_k In reply to Multiple forms in JavaScr ...

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.document.forms[j].elements.value

Regards,
Nise.

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums