0

I've been looking for a very simple code to rate limit a form on HTML (I use Django as a backend).

I did not find a solution to disable a button once it has been submitted.

Let's see a simple example:

<form method="POST" action="{% url 'example' %}">
{% csrf_token %}

<input name="input" id="input-1" placeholder="Test Field">

<button type="submit" id="btn-1">Submit</button>
</form>

How can we use simple Javascript 'onclick' to disable the button once it's clicked?

Kaiss B.
  • 249
  • 1
  • 12
  • You could do that, but that wouldn't prevent someone from opening dev tools and undisabling it, if they were so inclined. Or using PostMan et al to send form posts. Rate limiting is usually done on the server side. – James Sep 20 '22 at 20:39
  • 1
    https://stackoverflow.com/a/3366892/1024832 – Marc Sep 20 '22 at 20:41
  • Those solutions have issues with them (HTML5 validation, submitting the form twice, etc...) – Kaiss B. Sep 20 '22 at 20:54

0 Answers0