Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

224
Views
How to avoid submiting the form without selecting value in combo box c#

In my ASP.NET MVC project, create view consist of a main view and another couple of partial views.

So in one partial view, there is a combo box, I want to restrict it without selecting a value, so the user cannot submit the form.

I tried writing a javascript within that partial view, but it won't work. So want to know is there are any other ways to do this restriction?

 <div class="form-group row">
     @Html.Label("Select the Approver", htmlAttributes: new { @class = "control-label col-md-3" })
      <div class="col-sm-8">
       @Html.DropDownListFor(model => model.Approver_Id, new List<SelectListItem>(), new { @id = "ddlEmployees", @class = "js-dropdown" })
        @Html.ValidationMessageFor(model => model.Approver_Id, "", new { @class = "text-danger" })
  </div>
</div>

I cant use it on the model as required because some options in this combo box get hidden before submitting the form. So If I apply required to the model, the form does not get submitted for those options also.

Any suggestions would help me. :)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

if you don't want to handle this server-side you can do it client-side by JS.

$('#submitDemo').click( if(!$("drpval").val()>0) return false; );

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!