Application : MVC, C# ASP.Net
Engine : Razor
Problem : In .cshtml have drop down and text box. Based on that drop down, set text box mandatory
Thanks in Advance
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Srikanth ReddyPosted Jul 2, 2014, 6:01 AM
use this code in txtbox changed event or button click event or what ever event you want:
Code in Javasacript::
var a=$("#textboxid").val();
var b=$("#dropdownlistid option:selected").val();
if(b!=0)
{
if(a==null || a==0)
{
alert("Text Box Is Mandatory");
$("#textboxid").focus();
}
}
Post your code i will help you