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

179
Views
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 answers
Answer question

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 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!