Anicho
Anicho

Reputation: 2667

Form disappears within ascx page

So this is as should be on jsfiddle.
But when I put it within a .ascx page. Which loads within an .aspx page. The <form> decides to make itself null.
Anyone know why it is doing this?

More specifically:

document.getElementById('emvForm').submit();

The above line is returning null.

Okay so looking at the code I noticed I am getting:

<form id="1" runat="server">
    <form id="emvForm">
    </form>
</form>

Firefox ignores the second form because it is a nested form. The id remains the same it hasn't changed because runat not being defined on it.

Anyway of bypassing this?

Upvotes: 0

Views: 343

Answers (1)

Erwin
Erwin

Reputation: 4817

Looking at your code you can better do this:

instead of calling:

document.getElementById('emvForm').submit();

Return true:

return true;

Then modify your input button to this:

<input type="submit" value="Submit Form" id="SubmitButton" class="contactFormButton submit emailValid" onClick="return validForm();">

Now when you return true the form will be submitted and where your return false in the validForm function the forms stops the submit.

Upvotes: 1

Related Questions