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

  • SEARCH
  • Home
  • 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 800191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:15:16+00:00 2026-05-14T23:15:16+00:00

Im writing some logic in JavaScript using jquery, where i must check the input

  • 0

Im writing some logic in JavaScript using jquery, where i must check the input content against a REGEX pattern ex:

"^[a-zA-Z0-9_]*$"  //Alpha-numeric and _

The logic is almost done, i just have a little problem filtering the function key DEL,
my logic goes like this:

var FunctionsKey = new Array(8, 9, 13, 16, 35, 36, 37, 39, 46);

function keypressValidation(key) {
            if (config.regexExp != null) {
                if ($.inArray(key, FunctionsKey) != -1) {
                    return true;
                }
                else {
                    var keyChar = String.fromCharCode(key);
                    return RegexCheck(keyChar);
                }
            }
            return true;
        }

If the KeyCode is one of those in the array, i let it pass, if not i get the char and compare it against the REGEX.
The problem is: in some Browsers the DEL and ‘.’ (period sign) have the same key Code 46.

So is there a better logic to filter the function keys or must i write a condition for that case, maybe removing the 46 from the array and try to convert it to char and if is (.) let it go to the Regex function if not let it pass?
The other question will be are there more shared Key Codes in some browsers?

EDIT: My suggested solution wont work because it doesn’t matter which key the user pressed (DEL or period) i always get (.) as CHAR at least on OPERA and FF =(.

  • 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-14T23:15:16+00:00Added an answer on May 14, 2026 at 11:15 pm

    110 is the decimal key code, 46 is the DEL key.

    For some fun: put this in to see what you hit! EDIT: added a focused event

       /* handle special key press */
    $(document).ready(function() {
      function checkAKey(e) {
        var shouldBubble = true;
        switch (e.keyCode) {
          // user pressed the Tab 
          case 9:
            {
              alert("Tab hit, no bubble");
              shouldBubble = false;
              break;
            };
            // user pressed the Enter    
          case 13:
            {
              alert("Enter");
              break;
            };
            // user pressed the ESC
          case 27:
            {
              alert("Escape");
              break;
            };
        };
        /* this propogates the jQuery event if true */
        return shouldBubble;
      };
    
      $("*").keydown(function(e) {
        return checkAKey(e);
    
      });
    });
    

    OR

    $(document).ready(function() {
      /* handle special key press */
      function checkFieldKey(e, me) {
        var shouldBubble = true;
        switch (e.keyCode) {
          // user pressed the Enter
          case 13:
            {
              $(me).blur();
              $("#somewhereElse").focus();
              shouldBubble = false;
              break;
            };
        };
        /* this propogates the jQuery event if true */
        return shouldBubble;
      };
      /* user pressed special keys while in Selector */
      $("#myField").keydown(function(e) {
        return checkFieldKey(e, $(this));
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some logic trouble with a bit of jQuery I'm writing. I suspect
I’m writing some logic for academic purposes symbol source server. I have to check
I'm very new to jQuery and I'm writing some validation logic on a form.
I have a library that I created with some business logic that includes writing
I'm writing a customized reflective library for some specialized custom domain logic, and that
So I was writing some queries today and was using top 10 on a
I am currently writing a small web app using Asp.net MVC and jQuery mobile.
I´m writing some Shell code and, for some logic of programming, I need to
I am writing some application logic which can recognize malformed or malicious http post
I'm writing some JavaScript that interacts with a browser plugin (add-on in Firefox, ActiveX

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.