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

266
Views
how to use keypress event.preventDefault in modal form ? jquery

i've to use barcode reader, and the problem is when i show a barcode it saves by default, i tried this to prevent it, but it seems doesnt work for modal form

$(document).ready(function(){
        $(".inputs_imei").keypress(function(event){
            if (event.which == '15') {
                event.preventDefault();
            }
        });
        
    })
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="modal" id="exampleModal" tabindex="-1" role="dialog">
        <div class="modal-dialog" role="document">
          <div class="modal-content">
            <div class="modal-header">
              <h5 class="modal-title">Modal title</h5>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <div class="modal-body">
              <input type="number" c

<!-- begin snippet: js hide: false console: true babel: false -->

class="inputs_imei">
              <input type="number" class="inputs_imei">
              <input type="number" class="inputs_imei">
              <input type="number" class="inputs_imei">
              <input type="number" class="inputs_imei">
              <input type="number" class="inputs_imei">

            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-primary">Save changes</button>
            </div>
          </div>
        </div>
      </div>

it work for the other un modal fields, but for the modal inputs dont work! and act like save button every time that i try to input a number from the barcode reader ? thank you in advance ..

about 4 years ago · Santiago Trujillo
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!