Home > database >  Fixing login button
Fixing login button

Time:12-08

When I click the login button, it does not redirect me to anything. I stay on the same page. Once the user logs in, they should be redirected to another page.

This is my current code:

<div >
<p id="ob">Online Banking</p>
<p id="ml">Member Login</p>
<input id="userid" name="userid" type="text" placeholder="LoginID" />
<input id="mlButton" type="button" value="Login" />

<script> 
        function RedirectToLogin() { 
                var userId = document.getElementById("userid").value; 
                window.location.href = "https://www.securecuonline.com/fffcu/Login.aspx";
        } 
</script>

&nbsp;
<div><a  href="/lost-or-stolen-card/">Lost or Stolen Card</a>
<a  href="https://www.securecuonline.com/fffcu/Login.aspx">Make a Payment</a>
<a  href=" https://www.securecuonline.com/fffcu/EnrollOnlineBanking.aspx">Register your account</a></div>
</div>

CodePudding user response:

You never actually set up the function to be called. This should get it down with less code:

<form  action="/fffcu/Login.aspx">
<p id="ob">Online Banking</p>
<p id="ml">Member Login</p>
<input id="userid" name="userid" type="text" placeholder="LoginID" />
<input id="mlButton" type="submit" value="Login" />

<div><a  href="/lost-or-stolen-card/">Lost or Stolen Card</a>
<a  href="https://www.securecuonline.com/fffcu/Login.aspx">Make a Payment</a>
<a  href=" https://www.securecuonline.com/fffcu/EnrollOnlineBanking.aspx">Register your account</a></div>
</form>

CodePudding user response:

The issue with your code is that you are not calling the RedirectToLogin() function when the user clicks on the login button. You can fix this by adding an onclick attribute to the login button and setting it to the RedirectToLogin() function.

<div >
<p id="ob">Online Banking</p>
<p id="ml">Member Login</p>
<input id="userid" name="userid" type="text" placeholder="LoginID" />
<input id="mlButton" type="button" value="Login" onclick="RedirectToLogin()" />

<script> 
        function RedirectToLogin() { 
                var userId = document.getElementById("userid").value; 
                window.location.href = "https://www.securecuonline.com/fffcu/Login.aspx";
        } 
</script>

&nbsp;
<div><a  href="/lost-or-stolen-card/">Lost or Stolen Card</a>
<a  href="https://www.securecuonline.com/fffcu/Login.aspx">Make a Payment</a>
<a  href=" https://www.securecuonline.com/fffcu/EnrollOnlineBanking.aspx">Register your account</a></div>
</div>

After adding the onclick attribute, the RedirectToLogin() function will be called when the user clicks on the login button, and the user will be redirected to the specified page.

  • Related