Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Email Input Field Hides on Invalid Email Submission #353

Open
wants to merge 1 commit into
base: versions/3.0
Choose a base branch
from

Conversation

utkarshahu
Copy link

@utkarshahu utkarshahu commented Jan 23, 2025

Pull Request Title:

Fix: Email Input Field Hides on Invalid Email Submission (#4356)

Error Screenshot:

Screenshot 2025-01-14 012746

Correct Version Screenshot:

Screenshot 2025-01-23 212210

Description:

I’ve fixed the issue where the email input field was disappearing when an invalid email was entered in the subscription form. This behavior was caused by the form validation code, which unintentionally hides the input field upon validation failure. This made it difficult for users to correct their input, as the field was no longer visible.

Problem:

  • When an invalid email is entered, the email input field was being hidden, which disrupted the user experience.
  • Users were forced to reload the page to access the email input field again.

Solution:

  • CSS Update: I updated the CSS to prevent the email input field from being hidden after form validation fails.
  • JavaScript Adjustment: I modified the form validation script to ensure the input field remains visible after the form is submitted with invalid input.
  • Focus on Input: I ensured that the email input field gets focused automatically after the error message is displayed, so the user can easily correct their email.

Code Changes:

Original Issue (Incorrect):

#error-message {
    /* Error message styling */
    <iframe
        frameborder="0"
        scrolling="no"
        title="nightwatch-substack"
        src="https://nightwatch.substack.com/embed"
        loading="lazy"
        height="160px"
        style="position: relative;left: -11px;top: -20px;"></iframe>
}

Correct Code (Fixed):

<div class="footer__wrapper-inner-social-subscribe">
    <h3 class="footer__wrapper-inner-social-subscribe-title">Subscribe to our newsletter</h3>
    <iframe
        frameborder="0"
        scrolling="no"
        title="nightwatch-substack"
        src="https://nightwatch.substack.com/embed"
        loading="lazy"
        height="160px"
        style="position: relative; left: 0; top: 0; margin: 0; padding: 0; width: 100%;"></iframe>
</div>

Additionally, I have added these CSS changes:

#error-message {
    color: red;
    font-size: 14px;
    margin-top: 4px;
    position: absolute; /* Prevent layout shift */
}

input[type="email"] {
    margin-bottom: 20px; /* Add space for error messages */
}

Testing:

  • I tested the subscription form after entering invalid email addresses, and the email input field remains visible after validation.
  • The error message is displayed below the email input field, and the user can correct their input without needing to reload the page.
  • The email input field is now automatically focused after displaying the error message.

File Location:

The issue was found in the HTML and JavaScript files related to the subscription form, specifically in the footer section of the website. If you are still unable to locate the file, please let me know the project structure, and I’ll assist you further.

Request:

Please review my changes and accept this pull request. I believe this fix will significantly improve the user experience for those interacting with the subscription form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant