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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Srikanth Reddy142 reputationPosted Jul 2, 2014, 2:01 AM EDT
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