Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion frontend/registration.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<link rel="icon" type="image/png" href="assets/logo.png" />
<script src="js/navbar.js"></script>
</head>

<body>
<canvas id="matrix-canvas"></canvas>

Expand All @@ -30,7 +31,7 @@ <h1 class="page-title">Join the Leaderboard</h1>
your peers!
</p>

<form id="registrationForm">
<form id="registrationForm" novalidate>
<div class="form-group">
<label for="name" class="form-label">Full Name</label>
<input
Expand All @@ -41,6 +42,7 @@ <h1 class="page-title">Join the Leaderboard</h1>
placeholder="Enter your full name"
required
/>
<span class="error-msg" id="name-error"></span>
</div>

<div class="form-group">
Expand All @@ -58,6 +60,7 @@ <h1 class="page-title">Join the Leaderboard</h1>
<small class="form-help">
This should match your username on leetcode.com/u/username
</small>
<span class="error-msg" id="username-error"></span>
</div>

<div style="text-align: center">
Expand Down Expand Up @@ -357,6 +360,43 @@ <h1 class="page-title">Join the Leaderboard</h1>

form.addEventListener("submit", async (e) => {
e.preventDefault();
const nameVal = document.getElementById("name").value.trim();
const leetcodeVal = document
.getElementById("leetcodeId")
.value.trim();

// First, clear any previous error states
const nameInput = document.getElementById("name");
const leetcodeInput = document.getElementById("leetcodeId");

const nameTarget =
nameInput.closest(".form-input-bash-wrapper") || nameInput;
const leetcodeTarget =
leetcodeInput.closest(".form-input-bash-wrapper") || leetcodeInput;

const nameError = document.getElementById("name-error");
const leetcodeError = document.getElementById("username-error");

nameTarget.classList.remove("input-error");
leetcodeTarget.classList.remove("input-error");
nameError.textContent = "";
leetcodeError.textContent = "";

// Force DOM reflow to restart shake animation
void nameTarget.offsetWidth;
void leetcodeTarget.offsetWidth;

if (!nameVal) {
nameError.textContent = "$ Error: Full name is required_";
nameTarget.classList.add("input-error");
}
if (!leetcodeVal) {
leetcodeError.textContent =
"$ Error: LeetCode username is required_";
leetcodeTarget.classList.add("input-error");
}

if (!nameVal || !leetcodeVal) return;

// Hide form fields and show execution log
const fieldsets = form.querySelectorAll(".form-group");
Expand Down
33 changes: 33 additions & 0 deletions frontend/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1984,6 +1984,39 @@ body::-webkit-scrollbar-thumb {
background: #000;
}

.error-msg {
color: #ff4444;
font-family: "Courier New", monospace;
font-size: 0.8rem;
display: block;
margin-top: 5px;
}

Comment thread
Bluerock-crypto marked this conversation as resolved.
/* Input Error State */
.input-error {
animation: shake 0.3s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* Shake Animation */
@keyframes shake {
10%,
90% {
transform: translate3d(-1px, 0, 0);
}
20%,
80% {
transform: translate3d(2px, 0, 0);
}
30%,
50%,
70% {
transform: translate3d(-4px, 0, 0);
}
40%,
60% {
transform: translate3d(4px, 0, 0);
}
}
/* ── Tooltip ── */
.score-header {
display: flex;
Expand Down
Loading