user980411
user980411

Reputation: 1279

Forms within a form

I have three separate forms, which need to be part of a single 'larger' form. I can merge them to form a single form, but that is not my intention. I need to do something like this:

<form method="" action="">

    <form1 without method and action>

    </form>

    <form2 without method and action>

    </form>

    <form3 without method and action>

    </form>

</form>

such that the data from the three forms can be collectively sent to the 'outer' form. Is it possible?

Upvotes: 1

Views: 144

Answers (4)

Abhidev
Abhidev

Reputation: 7253

First of all nested forms are not allowed, instead what you can do is

<form>
<div class="step1">
feilds
</div>
<div class="step2">
feilds
</div>
<div class="step3">
feilds
</div>
</form>

wont this work for you?

Upvotes: 1

Susam Pal
Susam Pal

Reputation: 34204

No, nested forms are not allowed.

Upvotes: 3

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324650

It is invalid to put a form element inside a form element, and it is invalid to have a form with no defined method or action. Resulting behaviour is therefore undefined and, on the off-chance that it happens to work, it can't be relied on.

I can't see any reason for wanting/needing this kind of layout, when a single form should be fine.

Are you maybe looking for something like the <fieldset> element?

Upvotes: 6

Oded
Oded

Reputation: 499002

This is not valid HTML.

A FORM is not allowed to have nested forms.

From the DTD for HTML 4:

<!ELEMENT FORM - - (%block;|SCRIPT)+ -(FORM) -- interactive form -->

The -(FORM) explicitly excludes this.

You can have a single form and simply hide the unneeded elements using javascript.

Upvotes: 4

Related Questions