-
Notifications
You must be signed in to change notification settings - Fork 49
Refactor form validation: extract inline JS, fix duplicate attributes, improve accessibility, auto-remove spaces #317
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
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this, could you just auto-remove the space?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot please address the above comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.