Skip to content

Conversation

@alwin-m
Copy link
Owner

@alwin-m alwin-m commented Nov 25, 2025

Added error and success status indicators for username, password, and confirm password fields. Implemented animations for form elements and updated form validation.

Added error and success status indicators for username, password, and confirm password fields. Implemented animations for form elements and updated form validation.
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';
}
});

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 input event 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 confirm overrides the global confirm() 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

  1. Rename variable confirm to avoid shadowing: Example: confirmInput.
  2. Add safety checks before applying listeners.
  3. 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.

@alwin-m alwin-m added the documentation Improvements or additions to documentation label Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants