Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

225
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda