1

I want to disable button when user first click it so it must not save multiple record if a user have a slow connection. Im using asp.net mvc2

1
  • for jquery look at unbind(), might work - api.jquery.com/unbind Commented Aug 26, 2010 at 9:42

2 Answers 2

2

You can use jQuery's one(). With this, the event handler is executed only once. Inside the event handler you can disable or change the style.

Example from jQuery site:

$('#foo').one('click', function() {
  alert('This will be displayed only once.');
});
Sign up to request clarification or add additional context in comments.

Comments

1
$('#buttonId').click(function() {
    $(this).attr('disabled', 'disabled');
});

Of course you have to adjust the selector.

2 Comments

It does not work for me. This code prevent button click at all, so that form is not submitted once as it should.
Put this just before disabling button if you want your form been submitted $("form").submit();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.