As already mentioned, you cannot have a form inside a form. When the browser parses the HTML, it will fix it to the best of its ability. This behavior is unspecified and is not necessarily the same cross-browser. Because I was curious, I made this:
<form id="frmMainA">
<form class="2ndForm">
</form>
</form>
<form id="frmMainB">
<form class="2ndForm">
<input type="text"/>
</form>
</form>
<form id="frmMainC">
<input type="text"/>
<form class="2ndForm">
<input type="text"/>
</form>
</form>
When run in Chrome, it spits out this:
<form id="frmMainA">
</form>
<form id="frmMainB">
<input type="text">
</form>
<form id="frmMainC">
<input type="text">
<input type="text">
</form>
It did the same thing in FF and IE10. This means that when JS is running in modern browsers, you will only have #frmMain
and there won't be any .2ndForm
to unwrap
. If you need the form to have the class .2ndForm
, you can add it to #frmMain
.
var form = document.getElementById('frmMain');
form.className = form.className + ' 2ndForm');
Or
$('#frmMain').addClass('2ndForm');