[RESOLVED]MVC 5 Dynamically show/hide textbox

I need to dynamically show/hide a textbox based on the value of a combobox. ComboBox is bound to a property in the model.

When I change the selected i need to show the textbox.

use combox change event and jquery to hide / show the textbox.

Can you please post an example? Note: I am using @Html.EnumDropDownListFor

$('#myCombo').change(function(){
   //check the value and use
    textbox.hideElement()
    textbox.showElement()
 });

Hi preetahb,

Thanks for your post.

To do this you must attach an event on "change" event of the select (and hide the text input first). like this according to your own requirement to modify this and use it:

$("#Sub").hide();
$("#subject").change(function(){
    if ($(this).val() === "Other"){
        $("#Sub").show(); 
        $("#subject").hide();
    }else{
        $("#Sub").hide();
    }
});

Source link:

how to hide and show text box according to select value using jquery

Hope this can be helpful.

Best Regards,

Eileen

Leave a Reply