How not to let the user click more than once button using javascript [closed]

-2

How to not let the user click more than once button using javascript

<input type="submit" class="inviar" name="teste" id="testeid" value="Enviar">
    
asked by anonymous 24.08.2017 / 01:10

3 answers

1

In jquery you can do this:

$(document).ready(function () {
     $("#send").one('click', function (e) {  
           $(this).prop('disabled', true);
     });
});
    
24.08.2017 / 01:33
4

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.

    
24.08.2017 / 01:35
0

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

    
24.08.2017 / 01:31