Refactor form validation: extract inline JS, fix duplicate attributes, improve accessibility, auto-remove spaces#317
Refactor form validation: extract inline JS, fix duplicate attributes, improve accessibility, auto-remove spaces#317
Conversation
…validation Co-authored-by: wildan3105 <7030099+wildan3105@users.noreply.github.com>
…mment Co-authored-by: wildan3105 <7030099+wildan3105@users.noreply.github.com>
|
@copilot could you give me the screen recording of the UI after this change please? |
Co-authored-by: wildan3105 <7030099+wildan3105@users.noreply.github.com>
Here's a step-by-step demonstration of the form improvements: 🎬 Demo Flow
✅ All validation scenarios working correctly with improved accessibility and maintainability. |
| if (username === '') { | ||
| alert('Username cannot be empty or contain only spaces.'); | ||
| return false; // Prevent form submission | ||
| } |
There was a problem hiding this comment.
Instead of this, could you just auto-remove the space?
There was a problem hiding this comment.
Done in commit 7613cb9. The form now automatically removes all spaces (leading, trailing, and internal) from the username instead of showing an error.
Updated behavior:
" test user "→ auto-cleaned to"testuser"✅" "(whitespace-only) → shows "Username cannot be empty." ❌"validusername"→ passes validation ✅
The input field value is automatically updated to the cleaned username before form submission.
Co-authored-by: wildan3105 <7030099+wildan3105@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|





The form had duplicate
actionattributes, inlineonClickhandlers, and lacked accessibility labels. Validation also didn't handle whitespace-only input properly.Changes
Form markup (
src/pages/partials/body.handlebars):action=""attributeonClickhandler from submit buttonaria-label="Search GitHub user"to buttoninput-group-addonclass<script>block with validation logicValidation (
public/js/form-validation.js):onsubmithandleronsubmitBehavior
Instead of showing error messages for spaces, the form now automatically cleans the input:
" test user "→ Auto-cleaned to:"testuser"→ Form submits ✅" "(whitespace-only) → Error: "Username cannot be empty." ❌"validusername"→ Passes validation ✅Screenshot
Original prompt
This pull request was created from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.