0

Please help me solve this problem. In this project I want to do something when you select a value, I disable text input. I want this work to be done dynamically. Language technology project is: ASP.Net MVC 5. Photo is below:

enter image description here

Help me please.

1
  • if use jquery $('input').prop("disabled", true); Commented Jan 3, 2017 at 11:45

2 Answers 2

1
 @Html.TextBoxFor(m => m.Gender, new { @placeholder = "جنسیت", @class = "gender" ,onchange="myFunction()"})
@Html.TextBoxFor(m => m.NV, new { @placeholder = "انتخاب نظام وظیفه", @class = "NezamVazifeh" })


<script>
function myFunction(){
 var g= $("#Gender").val();
if(g=="fmale")
$("#NV" ).prop( "disabled", true );
}
</script>

or use

 function myFunction(){
 var g= $("#Gender").val();
if(g=="fmale")
 document.getElementById("NV").disabled = true;
}
Sign up to request clarification or add additional context in comments.

1 Comment

Could you let me know what is not working with the answer a gave, so I will be able to adjust and you to accept?
0

Use jQuery in click event to disable the input.

$('input').prop("disabled", true);  //use the input element id or class 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.