Answer the question
In order to leave comments, you need to log in
How can I make the button clickable once?
Hello!
I ran into a problem on the site, I have a form for sending applications to email and SMS, the fact is that when you send a request, a message pops up that the request has been sent and if you press the button 10 more times, 10 letters and messages will come. It doesn’t matter with letters, but the SMS service bans for a while and I can skip applications.
How to make it so that you can click on the button 1 time? Is there a css or html way to disable the button for a second click?
I would be very grateful to anyone who can help me with this issue.
Answer the question
In order to leave comments, you need to log in
We still need to think over server protection! Because the button is not a problem for some people)
in JS:
<button id="onetime">одноразовая кнопка</button>
<script>
window.onload = function() {
document.getElementById("onetime").onclick = function() {
this.disabled = 'disabled';
}
}
</script>
as written above
Immediately after the first click, make it disabled status.
and send a cookie
Since I touched on this topic: Yes, now the button works once, but there is a check whether the form is filled out. Is there a way to disable the button only on successful submission?
Something like, if span order_success appears, then the button is disabled, otherwise not?:
<span id="order_error" style="color:#red;"></span>
<span id="order_success" style="color:green;"></span>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question