Setting the disabled property of a form field (help needed)

Has anyone ever seen a case where you can’t use JavaScript to change the disabled property of a form field? I’ve used this exact same code elsewhere but for some reason it isn’t working for me. I get no error, but the property never gets updated. Here is the JavaScript I’m using:

if(offset == 0) { alert('set it to disble');$("prevbutton").disabled=true;} else { $("prevbutton").disabled=false; }

To be sure I wasn’t doing anything stupid, I did alert $(“prevbutton”) to confirm it was an input field. I also alerted the disabled status and it correctly said true for this button:

<input type="button" id="prevbutton" value="Prev" onclick="UpdatePage(pageOffset - pageSize);" />

As I said - I get no error at all - but it is almost like the button’s disabled field is readonly when it should be read/write.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate looking for his next gig. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support.

Lafayette, LA https://www.raymondcamden.com

Comments