creativecommons / creativecommons/search

[Bug] Validate and Trim Input Field

Open
#293 1 comment 0 reactions 0 assignees View on GitHub
🏁 status: ready for work 💻 aspect: code 🛠 goal: fix 🟩 priority: low
Dominant language
CSS
Stars
27
Forks
112
PR merge metrics
No merged PRs in 30d

Description

## Description
Currently, users can enter whitespace characters (spaces, tabs) in the search input field, which is not being handled properly. If the user submits the form with just whitespace, the form processes the input as a valid query. However, the form should treat input that contains only whitespace as invalid and display an error message, preventing submission.

## Reproduction

1. Open the search form.
2. Enter a query that contains only spaces or tabs.
3. Submit the form.

## Expectation
1. When the user submits the search form, any leading or trailing whitespace in the input should be removed (using trim()).
2. If the input is empty (or becomes empty after trimming), the form should show an error message indicating that the query cannot be blank.
3. The form should not proceed with the search if the query is invalid.

## Environment

- Device: laptop
- OS: Windows 11
- Browser: Chrome
- Version: 117
- Other info: 1920x1080

## Additional context
This issue affects form validation for searches and user experience when submitting search queries.

## Resolution

- [X] I would be interested in resolving this bug.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.