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

180
Vistas
how to apply numeric validation

I want to apply validation for integer but it's not working

function fnAllowNumeric() {
  if ((event.keyCode < 48 || event.keyCode > 57) && event.keyCode != 8) {
    event.keyCode = 0;
    alert("Accept only Integer..!");
    return false;
  }
}
<td>
  @Html.TextBoxFor(x => x.Items[i].ReceivedNumberOfCases, new { @class = "form-control text-right", @id="Received_"+ i ,@onkeyup = "outer.onChangeReceived("+ i +")" ,onkeypress="return fnAllowNumeric()"})
  @Html.ValidationMessageFor(x=>x.Items[i].ReceivedNumberOfCases,null,new{@class="text-danger",@id="recivedCasesMessage_"+ i })&nbsp;

</td>

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

0

Maybe you can try to use onblur:

<input onblur="return fnAllowNumeric(this)">

js:

function fnAllowNumeric(t) {
            if (($(t).val() < 48 || $(t).val() > 57) && $(t).val() != 8) {
                $(t).val(0)
                alert("Accept only Integer..!");
                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