Disabled property of js is not working with html???..help please.. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Disabled property of js is not working with html???..help please..

else{ attempt --; // Decrementing by one. alert("You have left "+attempt+" attempt;"); // Disabling fields after 3 attempts. if( attempt == 0) {document.getElementById("username").disabled = true ; document.getElementById("password").disabled = true; document.getElementById("submit").disabled = true; return false; } }

5th Mar 2017, 7:36 AM
Bhagwan Singh Rajpurohit
Bhagwan Singh Rajpurohit - avatar
2 Answers
+ 7
Check your html code, it works with: <input type="text" id="username"> <input type="password" id="password"> <input type="submit" id="submit"> ... maybe you haven't define ids but names ? Else, test write to property 'disabled' outside conditional branch: this way you can view if problem is within the property assignement or related to the conditional enbranchment ;)
5th Mar 2017, 7:17 PM
visph
visph - avatar
+ 1
got it ...thank you.
6th Mar 2017, 5:31 PM
Bhagwan Singh Rajpurohit
Bhagwan Singh Rajpurohit - avatar