Showing posts from February, 2016

Jquery code to check Radio Button on Text box focus

Here is sample code of jquery to select any radio button on text box focus. 

<script src=""></script>
$("#txtWidth").focusin(function () {
    $("#rbCustom").prop('checked', true);

<input type="radio" id="rbDefault" name="ResizeValue" value="DefaultSize" checked="checked" />Default<br />
<input type="radio" id="rbCustom" name="ResizeValue" value="CustomSize" />Custom  
<input id="txtWidth" type="text" />

Here txtWidth is a text box and rbCustom is a radio button. By default "rbDefault" radio button is checked. Using above script the "rbCustom" will get checked as soon as txtWidth text box is focused.