Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

226
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda