This snippet creates a simple login and signup form toggle using HTML, CSS,
and JavaScript.
It switches between forms with smooth transitions and updates the display
without reloading the page.
How to Use?
Include the HTML for both forms in a container, and use the provided JavaScript
to handle the toggle behavior.
No external libraries or frameworks are needed.
Credits
Built using basic DOM manipulation techniques and form styling commonly used
in interactive web UIs.
<div class="container">
<div class="form-container" id="login-form">
<h1>Login</h1>
<form>
<label for="username">Username</label>
<input type="text" id="username" name="username" required>
<label for="password">Password</label>
<input type="password" id="password" name="password" required>
<button type="submit">Login</button>
</form>
<p>Don't have an account? <a href="#" id="signup-link">Sign up</a></p>
</div>
<div class="form-container" id="signup-form" style="display: none;">
<h1>Sign Up</h1>
<form>
<label for="new-username">Username</label>
<input type="text" id="new-username" name="new-username" required>
<label for="new-email">Email</label>
<input type="email" id="new-email" name="new-email" required>
<label for="new-password">Password</label>
<input type="password" id="new-password" name="new-password" required>
<button type="submit">Sign Up</button>
</form>
<p>Already have an account? <a href="#" id="login-link">Login</a></p>
</div>
</div>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: 'Open Sans', sans-serif;
background-color: #222;
}
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.form-container {
width: 600px;
margin: 0 auto;
padding: 50px;
background-color: #333;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
color: #fff;
}
h1 {
text-align: center;
margin-bottom: 30px;
font-size: 36px;
color: #b38bff;
}
form {
display: flex;
flex-direction: column;
}
label {
margin-bottom: 10px;
font-size: 18px;
}
input {
padding: 12px;
border: none;
border-radius: 5px;
margin-bottom: 20px;
font-size: 16px;
color: #fff;
background-color: #555;
}
button {
padding: 10px;
background-color: #b38bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 18px;
transition: background-color 0.2s ease-in-out;
}
button:hover {
background-color: #8c5fb2;
}
a {
text-decoration: none;
color: #b38bff;
font-size: 18px;
transition: color 0.2s ease-in-out;
}
a:hover {
color: #8c5fb2;
}
p {
text-align: center;
margin: 8px;
}
const loginForm = document.getElementById('login-form');
const signupForm = document.getElementById('signup-form');
const loginLink = document.getElementById('login-link');
const signupLink = document.getElementById('signup-link');
loginLink.addEventListener('click', (event) => {
event.preventDefault();
signupForm.style.display = 'none';
loginForm.style.display = 'block';
setTimeout(() => {
signupForm.style.opacity = 0;
loginForm.style.opacity = 1;
}, 10);
});
signupLink.addEventListener('click', (event) => {
event.preventDefault();
loginForm.style.display = 'none';
signupForm.style.display = 'block';
setTimeout(() => {
loginForm.style.opacity = 0;
signupForm.style.opacity = 1;
}, 10);
});
$nomention
$onlyIf[$guildID!=;]
$allowUserMentions[]
$reply
$if[$message==]
Usage: !buy {item} {amount}
$else
$var[price1;$multi[1000;$message[2;amount]]]
$var[price2;$multi[5000;$message[2;amount]]]
$var[price3;$multi[10000;$message[2;amount]]]
$c[add more price variables as you add more items and the number inside multi is the actual price btw]
$if[$toLowercase[$message[1;item]==item1]]
$onlyIf[$getVar[clicker;$authorID]>=$var[price1];You don't have enough clicks to buy this item.]
$description[Successfully bought `$message[2;amount]` Item 1(s).]
$color[#2F3136]
$setVar[item1;$sum[$getVar[item1;$authorID];$message[2;amount]];$authorID]
$setVar[clicker;$sub[$getVar[clicker;$authorID];$var[price1]];$authorID]
$elseif[$toLowercase[$message[1;item]==item2]]
$onlyIf[$getVar[clicker;$authorID]>=$var[price2];You don't have enough clicks to buy this item.]
$description[Successfully bought `$message[2;amount]` Item2(s).]
$color[#2F3136]
$var[temp-item2;$multi[$message[2;amount];2]]
$c[The 2 at the end here is because this item gives a +2 multiplier]
$setVar[item2;$sum[$getVar[item2;$authorID];$var[temp-item2]];$authorID]
$setVar[clicker;$sub[$getVar[clicker;$authorID];$var[price2]];$authorID]
$elseif[$toLowercase[$message[1;item]==item3]]
$onlyIf[$getVar[clicker;$authorID]>=$var[price3];You don't have enough clicks to buy this item.]
$description[Successfully bought `$message[2;amount]` Item3(s).]
$color[#2F3136]
$var[temp-item3;$multi[$message[2;amount];3]]
$c[The 3 at the end here is because this item gives a +2 multiplier]
$setVar[item3;$sum[$getVar[item3;$authorID];$var[temp-item3]];$authorID]
$setVar[clicker;$sub[$getVar[clicker;$authorID];$var[price3]];$authorID]
$endif
$endif