Click here to Skip to main content
15,913,090 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
When i am clicking "Yes" Radio Button Text Box Should be Enabled and when I'm clicking on Save Button it's showing Validation for text Box .
My Problem is when I'm clocking on "No" Radio Button it's disabling the text box but validation Symbol is not clearing in mvc4
this is my view
HTML
 <td>Solar Panels</td>
                   <td>

                       @Html.RadioButton("rdoSolar_Panels", 1, new { name = "rdoSolarPanels", id = "rdoSolarPanelsY", onclick = "rdoSolarPanels1_Click()", tabindex = "8" })Yes
                 @Html.RadioButton("rdoSolar_Panels", 2, new { name = "rdoSolarPanels", id = "rdoSolarPanelsN", onclick = "rdoSolarPanels1_Click()", tabindex = "9" })No
              @Html.ValidationMessageFor(model => model.rdoSolar_Panels)
                   </td>

<td>If Yes,Count</td>
                   <td>

                           @Html.HiddenFor(model => model.intFacilityID, new { @Value = "6" })

                           @Html.TextBoxFor(model => model.intSolar_panelsCount, new { maxlength = 4, onkeypress = "return validate(event)", @class = "myclass", tabindex = 10, id = "txtYes", disabled = "disabled" })
                          @Html.ValidationMessageFor(model => model.intSolar_panelsCount)



                   </td>

this is java script code

JavaScript
function rdoSolarPanels1_Click() {
    if (document.getElementById("rdoSolarPanelsY").checked == true)
        $("#txtYes").attr("disabled", false);
    else if (document.getElementById("rdoSolarPanelsN").checked == true) {
        if(document.getElementById("txtYes").value=="")     
        {
              $("#txtYes.input-validation-error").addClass('input-validation-valid');
              $("#txtYes.input-validation-error").removeClass('input-validation-error');
             
          }
       
        $("#txtYes").attr("disabled", true);
        $("#txtYes").val(" ");

    }

}
Posted

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