Page 1 of 1

Submit login form via javascript function

Posted: 2022-01-21 20:06
by dlee
I would like to submit the login form via a javascript function. I replaced the form's submit button with my own button that calls the javascript function mysubmit(). The function submits the login form BUT almost instantly you see, at the top right of the index.php page, the words "You are not logged in" and it kicks you back to the login form. How can I make this work?
TD

/login.php:

Code: Select all

	<button type="button" class="btn btn-success" id="recaptcha_btn" onclick="mysubmit()">SUBMIT</button>
/hooks/header-extras.php (I added an id to the login form - id="login_form")

Code: Select all

	function mysubmit(){
	  document.getElementById("login_form").submit();
	}

Re: Submit login form via javascript function

Posted: 2022-01-22 14:46
by pbottcher
Hi,

you need to pass the signIn value in your submit.

So try to change

Code: Select all

	function mysubmit(){
	  	document.getElementById("login_form").submit();
	}

Code: Select all

	function mysubmit(){
		$j('form').append('<input name="signIn" style="display: none;" value=1>');
	  	document.getElementById("login_form").submit();
	}

Re: Submit login form via javascript function

Posted: 2022-01-22 16:41
by dlee
THAT DID IT, THANK YOU !!!
TD