1110
1110

Reputation: 6839

How to disable button so user can't enable it again

I have a simple button (for example with ID: new-product).
When I click on it it add partial view to the specified div on page.
Is it possible to set disable on new-product button so that user can't click on it again.
But also to prevent that user change something in browser and set it to enabled true again?

Upvotes: 0

Views: 664

Answers (2)

Ali Gangji
Ali Gangji

Reputation: 1501

You can set the disabled attribute on a button as sambormartin suggests, but a user can always change the HTML, CSS, and javascript from their browser. You cannot rely on client side validation. You must validate all inputs on the server side.

Upvotes: 2

sambomartin
sambomartin

Reputation: 6813

this should do the trick

$('#new-product').attr('disabled','disabled')

to enable

$('#new-product').removeAttr('disabled');

or you can set attr to ""

$('#new-product').attr('disabled', '');

Upvotes: 2

Related Questions