How to not let the user click more than once button using javascript
<input type="submit" class="inviar" name="teste" id="testeid" value="Enviar">
How to not let the user click more than once button using javascript
<input type="submit" class="inviar" name="teste" id="testeid" value="Enviar">
In jquery you can do this:
$(document).ready(function () {
$("#send").one('click', function (e) {
$(this).prop('disabled', true);
});
});
Just add disabled
to disable the button, so be sure to add the attribute when clicked.
One of the options is simply to add in onClick
:
<button onClick="this.disabled=true;">Teste</button>
You can also do it by Javascript, there is no need to use JQuery:
document.getElementsByTagName("button")[0].addEventListener('click', function(){
this.disabled = true;
});
<button>Teste</button>
Remembering that the user can remove this behavior, as well as replicate requests in other ways.
What you can do is to click the button, change the 'disabled' property of the button to 'true':
Example:
document.getElementById ("myBtn"). disabled = true;
Source: Button disabled property