<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script> function check() { var value = $('input[name=opt]:checked').val(); if (value == 'Yes') $('#txtbox').show(); else $('#txtbox').hide(); if (value == 'Yes' && $('#txtbox').val() == '') { alert('Please enter the mandatory field'); return false; } else { alert('submit!!'); return true; } } $(document).ready(function () { $('input[name=opt]').change(function () { if (this.value == 'Yes') { $('#txtbox').show(); } else { $('#txtbox').hide(); } }); }); </script> </head> <body> <input type="radio" name="opt" checked value="Yes"> Yes<br> <input type="radio" name="opt" value="No"> No<br> <input type="text" id="txtbox" /> <button onclick="check()">submit</button> </body> </html>
you can use $("p").hide(); and $("p").show();
$('#element').click(function() { if($('#radio_button').is(':checked')) { $("#texboxid").show(); }else{ $("#texboxid").hide(); } });
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)