1

So I have a javascript function that shows the register form after the onclick but it doesn't refresh because it is on the same page. It just loads another form in. But when I have the Reset Password page and I want a button that goes directly to the register form instead of the standard login form and that you have to click manually on the register button.

How can I fix that after the click on the a href the page refreshes and that it will use the javascript code so it will show the register form instead of the login form.

$('.register-pass-reset').click(function(){
    // Switches the forms
    ('.form').animate({
        height: "toggle",
        'padding-top': 'toggle',
        'padding-bottom': 'toggle',
        opacity: "toggle"
    }, "slow");
    $('.help-block').remove();
    $('.toggle').html($('.toggle').html() == 'Register' ? 'Login' : 'Register');
});

The a href:

<a class="register-pass-reset" href="{{ url('/login') }}">
2
  • you want to show the register form instead of login form(default form) when redirected to this page by reset password button in another page. Commented Jun 28, 2016 at 17:36
  • @M.Tanzil Yes like this gyazo: gyazo.com/86919845ac4bea1e5ef8061613df184f Here you can see how it looks Commented Jun 28, 2016 at 17:39

2 Answers 2

1

You'll want to link to url('/login#register'), then detect the hash in the JS when the page loads:

window.onload = function(){
    if(window.location.hash && window.location.hash == "#register") {
        //Change Login To Register Form
    }
}
Sign up to request clarification or add additional context in comments.

Comments

1

For detail about Web Storage Click here

You should use HTML WEB STORAGE to keep track of page. Like if reset_password button is pressed then store a key with yourself in storage.

Then in the other page access that key and show the register form on the basis of its value and then reset the key to null in storage for future usage.

Here is how to use HTML web storage.

When reset_password button is pressed add the below code in its click event.

localStorage.setItem("register", "true");
// where register is the key and its value is true

In another page access this key in its DOM ready function like

$(function(){
   if(localStorage.getItem("register") === "true") {
      // show your register form and reset the storage.
      localStorage.setItem("register","");
   } else { 

   }
});

1 Comment

HTML Web Storage has known issues in IE8 up to IE 11. Why would you recommend it to be used?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.