Click here to Skip to main content
14,364,319 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have jquery tabs login and sign up i need when the registration page has errors to trigger the registration page to open but the default first page is login
<div class="auth-buttons" >
                <a class="btn" id="btn-login">Login</a>
                <a class="btn" id="btn-register">Register</a>

                </div>
<div id="lgn" class="btns">
        <form method="POST" action="{{ route('login')}}" autocomplete="off">
</div>

<div id="reg" class="btns">
 <form method="POST" action="{{ route('register')}}" autocomplete="off">
</div>
<pre lang="Javascript"><script>

        $('#reg').hide();

        $('#btn-login').click(function(){
            $('#reg').hide();
            $('#lgn').show();
        });
        $('#btn-register').click(function(){
            $('#lgn').hide();
            $('#reg').show();
        });
        </script>

I have tried this script but its not working, when register has errors it displays the errors but it goes back to login first

What I have tried:

<script>

    $(function() {
    let hasErrors = document.getElementsByClassName('errorClass').length > 0;

    if(hasErrors)
    {
        $('#btn-register').trigger('click');
    }

       });
        </script>
Posted
Updated 2-Nov-19 2:43am
v2
Comments
Richard Deeming 1-Nov-19 14:27pm
   
Why are you clicking the button when there are validation errors? Shouldn't you be clicking the button when there aren't any validation errors instead?

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100