I have two div
classes, one for login and one for signup. Now, for the login div
, there’s underlined text which asks to Sign Up, and for the signup div
, there’s underlined text which asks to Log In. When these texts are clicked, the respective div
should have no display and the other div
should be displayed.
HTML:
<div class="login">
<h2 class="textHead">MedConnect</h2>
<h2 class="logintxt">Log In to Your Account</h2>
<input type="text" class="loginemailtxt" name="email" placeholder="Email Address">
<input type="password" class="loginpwdtxt" name="password" placeholder="Password">
<button class="loginbtn" type="button" name="button">Log In</button>
<h5 id="signuptext" style="margin-top: 50px; text-align: center;">Don't have an Account? <u style="cursor: pointer;">Sign Up</u></h5>
<h6 style="text-align: center;">By clicking "Log In", you log back into your Existing Account</h6>
<div id="errorMsg">
<h5 id="loginNoEmail">Please enter your email address</h5>
<h5 id="loginNoPassword">Please enter your password</h5>
<h5 id="loginIncorrectCreds">Incorrect Email or Password</h5>
</div>
</div>
<div class="signup" style="display: none">
<h2 class="textHead">MedConnect</h2>
<h2 class="logintxt">Create a New Account</h2>
<input type="text" class="signupnametxt" name="Name" placeholder="Name">
<input type="text" class="signupemailtxt" name="Email" placeholder="Email Address">
<input type="password" class="signuppwdtxt" name="Password" placeholder="Create Password">
<button class="signupbtn" type="button" name="Button">Sign Up</button>
<h5 id="logintext" style="margin-top: 50px; text-align: center;">Already a Member? <u style="cursor: pointer;">Log In</u></h5>
<h6 style="margin-top: 5px; text-align: center;">By clicking "Sign Up", you agree to our <u style="cursor: pointer;">Terms</u> and <u style="cursor: pointer;">Privacy Policy</u></h6>
<div id="errorMsg">
<h5 id="loginNoEmail">Please enter your email address</h5>
<h5 id="loginNoPassword">Please enter your password</h5>
<h5 id="loginIncorrectCreds">Incorrect Email or Password</h5>
</div>
</div>
JavaScript (creating a variable for each element required):
<script type="text/javascript">
var signuptxt = document.getElementById('signuptext');
var logintxt = document.getElementById('logintext');
var loginDiv = document.getElementsByClassName('login');
var signUpDiv = document.getElementsByClassName('signup');
</script>
2
Answers
According to me, you are asking a functionality like this:
Signup Button => clicked => display signup div and hide the login div and when
Login Button => clicked => display login div and hide the signuo div.
If this is the case, then this should work: