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

134
Vistas
Submit button not consistently firing

I have an asp.net core razor form with a submit button. When the user clicks 'Update', the form calls a JavaScript function to prompt the user if they are sure they want to complete the request. This functionality has been working, but starting last week, the form will occasionally not save despite the user confirming that they want to complete the request.

<div class="form-group">
    <label asp-for="Requests.Complete" class="lblReq"></label>
    <select id="isComplete" asp-for="Requests.Complete" class="inputReq switch-disable">
        <option value="N">N</option>
        <option value="Y">Y</option>
    </select>
        <span asp-validation-for="Requests.Complete" class="text-danger"></span>
</div> 

   
<div class="form-group">
    <input type="submit" value="Update" class="btn btn-primary" onclick="return CompleteOrNot()" />
</div>


@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}

<script type="text/javascript">
    $(document).ready(function () {
        
    function CompleteOrNot() {
        var value = ($("#isComplete").val());            
        if (value == "Y")
        {
            var retVal = confirm("Are you sure you want to complete this request?");
            window.history.go(-1);                
            if (retVal == true) {                    
                return true;
            }                
        }                   
    }
}

The user always gets prompted if they want to complete the request and sometimes the post goes through and other times it acts as though the user said no to the prompt (even though they did not). Do you have any suggestions on how to troubleshoot/correct this issue?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you want to submit the form when retVal is true,try to use the following code

<form method="post" id="myForm">
    <div class="form-group">
    <label asp-for="Requests.Complete" class="lblReq"></label>
    <select id="isComplete" asp-for="Requests.Complete" class="inputReq switch-disable">
        <option value="N">N</option>
        <option value="Y">Y</option>
    </select>
        <span asp-validation-for="Requests.Complete" class="text-danger"></span>
</div> 


    <div class="form-group">
        <input type="button" value="Update" class="btn btn-primary" onclick="CompleteOrNot()" />
    </div>
</form>
@section Scripts {
    @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}

    <script type="text/javascript">
        function CompleteOrNot() {
            var value = ($("#isComplete").val());
            if (value == "Y") {
                var retVal = confirm("Are you sure you want to complete this request?");
                if (retVal == true) {
                    $("#myForm").submit();
                }
            }
        }
        $(document).ready(function () {

            
        })

    </script>
}
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