Checkbox - unchecking if other box is checked
I used checkboxes recently to allow a box to be selected if yes or if no. The problem is that the boxes can both be checked at the same time. I'd like them to toggle the other if checked.
So if "Yes" is checked, then "No" would uncheck.
Below is my code. The buttons work great. The checking to see if a value is true, then setting it to false works...but the checkbox button still reads as though selected.
Any help you have would be appreciated.
- $(function() {
- $( "#checkWelcomeFormat" ).buttonset();
- });
- $(function() {
- $( "#checkChildrenFormat" ).buttonset();
- });
- $("#checkWelcomeYes").on("change", function(event){
- setWelcome($(this).val());
- if($("#checkWelcomeNo").prop('checked') == true)
- {
- $("#checkWelcomeNo").removeClass( "ui-state-active" ).addClass("ui-state-default");
- $("#checkWelcomeNo").prop("checked", false);
- }
- });
- $("#checkWelcomeNo").on("change", function(event){
- setWelcome($(this).val());
- if($("#checkWelcomeYes").prop('checked') == true)
- {
- $("#checkWelcomeYes").removeClass( "ui-state-active" ).addClass("ui-state-default");
- $("#checkWelcomeYes").prop("checked", false);
- }
- });