Last active
September 3, 2015 15:43
-
-
Save christopherbauer/d8494c63386c60c4535d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function disableChecker(checkSelector, disableValue, targetSelector) { | |
| var optionValue = $(checkSelector).val(); | |
| if (optionValue === disableValue) { | |
| $(targetSelector).prop("disabled", true); //Disable target | |
| } else { | |
| $(targetSelector).prop("disabled", false); //Enable target | |
| } | |
| } | |
| function DisableIf(checkSelector, disableValue, targetSelector) { | |
| $(checkSelector).on("change keyup blur", function() { | |
| disableChecker(checkSelector, disableValue, targetSelector); | |
| }); | |
| disableChecker(checkSelector, disableValue, targetSelector); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <select id="disableSource"> | |
| <option value="0">Disable Next</option> | |
| <option value="1">Enable Next</option> | |
| </select> | |
| <input type="text" id="disableTarget" /> | |
| <input type="text" id="disableTarget2" /> | |
| <select id="disableSource"> | |
| <option value="0">Disable Next</option> | |
| <option value="1">Enable Next</option> | |
| </select> | |
| <input type="text" id="disableTarget" /> | |
| <input type="text" id="disableTarget2" /> | |
| <script src="https://code.jquery.com/jquery-1.11.3.js"></script> | |
| <script type="text/javascript"> | |
| //Please note that at this time, order is important! | |
| DisableIf("#disableSource", "0", "#disableTarget"); | |
| DisableIf("#disableTarget", "Disable Next", "#disableTarget2"); | |
| DisableIf("#disableSource", "0", "#disableTarget2"); | |
| <script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DisableIf("#disableSource", "0", "#disableTarget"); | |
| DisableIf("#disableTarget", "Disable Next", "#disableTarget2"); | |
| DisableIf("#disableSource", "0", "#disableTarget2"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment