Enhance signup form with validation and animations#5
Open
Conversation
Added error and success status indicators for username, password, and confirm password fields. Implemented animations for form elements and updated form validation.
alwin-m
commented
Nov 25, 2025
Comment on lines
+198
to
+210
| // Confirm password check | ||
| const confirm = document.getElementById('confirm'); | ||
| const confirmStatus = document.getElementById('confirm-status'); | ||
| confirm.addEventListener('input', () => { | ||
| if (confirm.value !== pass.value) { | ||
| confirmStatus.style.color = 'var(--error)'; | ||
| confirmStatus.textContent = 'Passwords do not match'; | ||
| } else { | ||
| confirmStatus.style.color = 'var(--success)'; | ||
| confirmStatus.textContent = 'Passwords match'; | ||
| } | ||
| }); | ||
|
|
Owner
Author
There was a problem hiding this comment.
Confirm Password Check
Summary
This JavaScript snippet handles real-time validation of the Confirm Password field by checking whether the value matches the primary password input. It updates UI feedback instantly using color-coded messages.
Strengths
- Real-time validation: The use of an
inputevent listener ensures instant feedback. - Good UX cues: Color changes via CSS variables (
var(--error)/var(--success)) provide quick user understanding. - Simple and understandable: The logic is concise and readable.
Issues / Risks
- Variable name shadowing: Using
const confirmoverrides the globalconfirm()browser API. This is not a breaking issue but is considered bad practice. - No debounce: The validation runs on every keystroke; harmless here, but debouncing could be considered for heavier logic.
- Missing null checks: If elements are not found in the DOM, this will throw errors.
Recommendations
- Rename variable
confirmto avoid shadowing: Example:confirmInput. - Add safety checks before applying listeners.
- Optional: Use a small helper function for clarity.
Revised Example
// Confirm password check
const confirmInput = document.getElementById('confirm');
const confirmStatus = document.getElementById('confirm-status');
if (confirmInput && pass) {
confirmInput.addEventListener('input', () => {
const match = confirmInput.value === pass.value;
confirmStatus.style.color = match ? 'var(--success)' : 'var(--error)';
confirmStatus.textContent = match ? 'Passwords match' : 'Passwords do not match';
});
}If you want, I can apply this improved version directly into your signup page document.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added error and success status indicators for username, password, and confirm password fields. Implemented animations for form elements and updated form validation.