Skip to content

bug: Missing client-side validation for "Subject" dropdown in Contact Form #34

Description

@Adithyakp86

Describe the bug

The Contact Form page (views/contact.ejs) is missing client-side validation for the Subject dropdown.

While the Name, Email, and Message fields have client-side validation and the required attribute, a user can submit the form with "Select a subject" still active. This bypasses the client-side check and triggers a backend Express validation error (Subject is required.) instead of blocking the submission on the client side.

To Reproduce

  1. Navigate to /contact.
  2. Fill in the Name, Email, and Message fields.
  3. Leave the Subject dropdown set to its default option ("Select a subject").
  4. Click Send Message.
  5. Observe the validation error displayed at the bottom of the form, returning from the server validation.

Expected behavior

The form should prevent submission on the client side and prompt the user to select a valid subject before hitting the API endpoint.

Proposed Solution

  1. Add the required attribute to the <select> tag in views/contact.ejs:
    <select id="subject" name="subject" required>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions