Reputation: 3240
I have a commenting system that I build which is similar to typical social media like Facebook. The user can post a comment beneath a thread. As it stands, someone could type something and hit enter extremely fast and over and over again and basically "spam" the system.
What would be the best method to prevent this type of flooding with javascript/jQuery?
There's a hidden input/submit button that's triggered when they hit enter, so I want to attach some type of event on that button:
Only allow X amount of comments during session and warn the user when this is breached.
<input id="comment" placeholder="Post a comment" />
<a id="post" class="btn">Post</a>
Upvotes: 0
Views: 123
Reputation: 943548
What would be the best method to prevent this type of flooding with javascript/jQuery?
There is no good way to use client side code to do this. Don't ask the client to prevent itself from flooding. Implement rate limiting (based on username or ip address) on the server.
Upvotes: 1