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>