Similar issue. What a pain.
In the end I've put a form in the master page (this way it isn't inside another form):
<form method="post" id="asp-form-hack" style="display: none;"></form>
Then, in the aspx pages, I use it like this:
<script>
$(document).ready(function () {
var $loginButton = $("#login-button");
var loginForm = document.forms["asp-form-hack"];
loginForm.action = "<page-to-postback>.aspx";
$loginButton.on("click", Login);
function Login() {
// read values from input fields in the page
var username = $("#t_username").val();
var password = $("#t_password").val();
// create input elements with the same values
var usernameInput = document.createElement("input");
usernameInput.name = "txtUsername";
usernameInput.type = "text";
usernameInput.value = username;
var passwordInput = document.createElement("input");
passwordInput.name = "txtPassword";
passwordInput.type = "password";
passwordInput.value = password;
// append the input elements to the form
loginForm.appendChild(usernameInput);
loginForm.appendChild(passwordInput);
// setTimeout prevents your page from understanding
// that you are submitting from another form
setTimeout(function () {
loginForm.submit();
}, 0);
}
});
</script>
Please note that this method allows posting to other domains