Reset default value on radio button using jquery

dartzman

New Member
I'm having an issue with some jquery that I am using in an asp.net mvc3 application that handles mutually exclusive radio buttons. The check/unchecking part works fine but the value of the radio button control is left with it's true value even though it is unchecked.Here is the jquery that I'm using:\[code\]$('.customRadio').click(function () { var checkState = $(this).attr('checked'); $('.customRadio:checked').each(function () { $(this).attr('checked', false); }); $(this).attr('checked', checkState);});\[/code\]I've tried setting the .val('myValue') property with jquery like so but it's not working:\[code\]$(this).val($(this).getAttribute("falsevalue"));\[/code\]Here is the rendered html:\[code\]<div class="one columns " style="min-width: 64px;"> <label for="Approve" class="hide-on-phones" style="white-space: nowrap">Approve</label> <span class="clearfix hide-on-phones"></span> <label for="Approve" class="show-on-phones">Approve &nbsp; </label> <span class="clearfix show-on-phones"></span> <input class="customRadio" falsevalue="http://stackoverflow.com/questions/14528514/N" id="Approve" name="Approve" truevalue="http://stackoverflow.com/questions/14528514/Y" type="radio" value="http://stackoverflow.com/questions/14528514/N"> </div><div class="one columns " style="min-width: 50px;"> <label for="Reject" class="hide-on-phones" style="white-space: nowrap">Reject</label> <span class="clearfix hide-on-phones"></span> <label for="Reject" class="show-on-phones">Reject &nbsp; </label> <span class="clearfix show-on-phones"></span> <input class="customRadio" falsevalue="http://stackoverflow.com/questions/14528514/Y" id="Reject" name="Reject" truevalue="http://stackoverflow.com/questions/14528514/N" type="radio" value="http://stackoverflow.com/questions/14528514/Y"> </div>\[/code\]I am inspecting the elements with Chrome.Anyone have any ideas or suggestions?Thank you kindly,Nathan
 
Back
Top