How to make the button disabled based on these two conditions | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to make the button disabled based on these two conditions

Hello, how do I make the calculate button disabled when either only 1 input has a value or MORE THAN 2 inputs have values? Also it should be disabled when atleast one input is 0? I have the css styles when the button should be disabled. Thanks in advance https://code.sololearn.com/WQ383vPhQOMw/#js

27th Apr 2020, 6:38 PM
Evans
Evans - avatar
3 Answers
+ 2
Just use keyup event on input box. Call a function on that event and make button disabled.
27th Apr 2020, 6:46 PM
A͢J
A͢J - avatar
+ 1
https://www.w3schools.com/jsref/prop_pushbutton_disabled.asp JS document.getElementById("myBtn").disabled = true; JQuery $(selector).prop('disabled', true); or $(selector).attr('disabled', true);
27th Apr 2020, 8:07 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Thanks
28th Apr 2020, 9:30 AM
Evans
Evans - avatar