Click here to Skip to main content
15,744,304 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello All,

I am working on mvc application where i have two radio button. On radio button selection change i hide and show some controls.At the normal stage controls are show and hide on radio button change but when i post method is called and bind database value to radio button controls should be show and hide based on value which is bind but event is not fired.below are the code for reference.

I put debugger on the javascript and i get that $("input:radio[name='ApplicantType']").change(function () { this is not event to fired.debugger lost the focus on this line.

@Html.RadioButtonFor(m => m.ApplicantType, "INDV", new { @checked = "checked" })<span>Individual</span>
                            @Html.RadioButtonFor(m => m.ApplicantType, "ORG")<span>Organization</span>

<script type="text/javascript">
        $(document).ready(function () {
            $("#CustName").prop("disabled", true);
            $("#ApplicantName1").text("Applicant Name");
            $("input:radio[name='ApplicantType']").change(function () {
                var Selectedvalue = $(this).val();
                if (Selectedvalue == "INDV") {
                    $("#Entity").prop("disabled", true);
                    $("#CustName").prop("disabled", true);
                    $("#ApplicantName").text("Applicant Name");
                    $("#lblDOBProof").text("DOB/Age Proof");

                else {
                    $("#Entity").prop("disabled", false);
                    $("#ApplicantName").text("Company Name");
                    $("#CustName").prop("disabled", false);
                    $("#lblDOBProof").text("DOI Proof");


What I have tried:

I use (document).ready(function () but its not working after post.
Updated 4-Aug-16 0:41am
Karthik_Mahalingam 4-Aug-16 2:19am    
try adding this at the bottom of the page
(document).ready(function ()

Use .trigger function on change function like this.
Share this answer
$(document).ready(function() {
$('input[type=radio][name=ApplicantType]').change(function() {
if (this.value == "INDV") {
alert("Your Code");
else if (this.value == "ORG") {
alert("Your Code");
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900