There is a javascript question: How to prevent form from being submitted?. It has been asked more than five years ago and a lot changed since then. Basically, all the answers recommends using obsolete inline events (onsubmit
HTML attribute) or assigning event handler to onsubmit
property of DOM element, which is also not a good idea. I think these answers are bad, so I downvoted them, explained my point in comments (some of them has already been deleted) and posted my own answer.
After a few hours, the author of the highest-scoring answer noticed that his answer is obsolete. However, instead of writing his own solution, he literally copy-pasted the code from my answer to his own, without even giving me any credit. Also, he posted this code as third solution, so most of the users would still read only the first or second solution. I appreciate that he wanted to improve his answer, but I think that:
- He should write his own code, and possibly give me some credit.
- He should replace the outdated answer with an up-to-date solution, not add it as an alternative.
What should be done with it?
I think fixing this question is a priority, because it has over 100k views and still a lot of people come there and learn bad coding practices (which also leads to asking new questions containing code following these coding practices).
Edit:
The edit on this answer has been rolled back and it also has been made CW, so the problem with stealing my answer has been solved. However, I think that there still is a problem with this answer being obsolete. Actually, I'm not sure if calling it "obsolete" is appropriate, because it has been wrong at the moment of posting it, due to wide browser support of .addEventListener()
. I think that it received so many upvotes because in that time nobody cared about code quality. If you have any doubts, I explained broader why .addEventListener()
is the best way to register event handlers in another answer.
Related: