Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

document.getElementById('btnid').disabled is not working in firefox and chrome

Tags:

I'm using JavaScript for disabling a button. Works fine in IE but not in FireFox and chrome, here is the script what I'm working on:

function disbtn(e) {      if ( someCondition == true ) {        document.getElementById('btn1').disabled = true;     } else {        document.getElementById('btn1').disabled = false;     } 

And in my html I have:

<input type="button" id="btn1" value="submit" /> 
like image 450
steeve Avatar asked Jul 31 '12 09:07

steeve


1 Answers

use setAttribute() and removeAttribute()

function disbtn(e) {      if ( someCondition == true ) {        document.getElementById('btn1').setAttribute("disabled","disabled");     } else {        document.getElementById('btn1').removeAttribute("disabled");     } } 

SEE DEMO

like image 137
Ahsan Khurshid Avatar answered Oct 09 '22 17:10

Ahsan Khurshid