Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7538097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:01:45+00:00 2026-05-30T07:01:45+00:00

The following simple jQuery function works perfectly on Mozilla Firefox(5.0) but doesn’t work on

  • 0

The following simple jQuery function works perfectly on Mozilla Firefox(5.0) but doesn’t work on Internet Explorer(4.0).

$(document).ready(function()
{
     $("#textFieldId").keypress(function(event)
     {
         if (event.keyCode==46 || event.keyCode==8|| event.keyCode==9 || event.keyCode>=35 && event.keyCode<=40)
         {
              // let it happen, don't do anything
         }
         else
         {
              if (event.charCode<48 || event.charCode>57 || event.charCode==16)
              {
                   event.preventDefault();
              }
         }
    });
});

This function is meant to allow only digits in a given text field. What changes should be made to it so that it can work on Internet Explorer?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:01:46+00:00Added an answer on May 30, 2026 at 7:01 am

    Try this, if you are looking for any other alternative.

      function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;
    
         return true;
      }
    

    and HTML as

     <INPUT id="txtChar" onkeypress="return isNumberKey(event)" type="text" name="txtChar">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the following code works perfectly in FireFox 7, but when pulling up the same
I have a simple script in jQuery that works perfectly with jQuery 1.5.2 as
I have the following simple function: private void EnableDisable941ScheduleBButton() { if (this._uosDepositorFrequency.Value != null)
I'm new to jquery and am hoping this is a simple issue, but am
I have an issue with internet explorer dealing with JQuery or JQuery dealing with
I have the following Javascript/jQuery function: function addEventHandler(){ $(div).mouseenter(function() { $(this).html(Over); }).mouseleave(function() { $(this).html(Out);
with following code qTip works for me and generates tooltips: $('a.ppname[rel]').live('mouseover', function() { $(this).qtip(
I'm making a simple jQuery navigation system but I am far from expert at
I am at a loss here with some simple jQuery. I have the following
I have here a simple jQuery example wherein an element should be hidden. But

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.