简体   繁体   中英

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?

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', '');

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM