I have two radio buttons with one input text, when I insert value more than 12 it will automatically check RadioBtn2 otherwise it will check RadioBtn1
It works OK but when I return to textbox and change the value again it not working until I refresh the page
$(function() {
$('#field222').change(function() {
var text_value = $("#field222").val();
if (text_value >= '12') {
$('input:radio[id="RadioBtn2"]').attr('checked', 'checked');
} else {
$('input:radio[id="RadioBtn1"]').attr('checked', 'checked');
}
})
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type='text' class='input-lg' id='field222'>
<input type='radio' name='Radios' id='RadioBtn1' value='option1' checked>First
<input type='radio' name='Radios' id='RadioBtn2' value='option1' >Secend