Skip to content

Commit 8a8453c

Browse files
justin808claude
andcommitted
Fix validation logic to show both error messages when both fields are blank
Changed the if/else-if structure to two independent if checks so that both "Author: can't be blank" and "Text: can't be blank" messages are displayed when both form fields are empty. Before: Only one error message would show due to else-if chain After: Both error messages show when both fields are blank 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7e92502 commit 8a8453c

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

client/app/controllers/comments_controller.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ export default class CommentsController extends Controller {
2222
errorList.innerHTML = '';
2323
if (!inputAuthor.value) {
2424
errors.push('Author');
25-
} else if (!inputText.value) {
26-
errors.push('Text');
27-
} else {
28-
errors.push('Author');
25+
}
26+
if (!inputText.value) {
2927
errors.push('Text');
3028
}
3129
errors.forEach((error) => {

0 commit comments

Comments
 (0)