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 8231947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:39:52+00:00 2026-06-07T17:39:52+00:00

The Question To help avoid end-user confusion, I want to add an alert message

  • 0

The Question

To help avoid end-user confusion, I want to add an alert message that pops up if/when the user clicks any other key [“alert(‘Only Numerical data allowed’)”]. So if they press the ‘k’ the above message will pop up. Can anyone see how to set this code within this code base

  • jsfiddle: http://jsfiddle.net/EN8pT/4/

The Code

jquery:

$('input.numberinput').bind('keypress', function (e) {
    var w = e.which;
    return (w != 8 && w != 0 && (w < 48 || w > 57) && w != 46) ? false : true;
});

​

html

<div class="containercontent">

         <div class="label">Enter a number:</div>
        <input type="text" name="txtNumber1" id="txtNumber1" value=""  class="numberinput" />

         <div class="label">Enter a number:</div>
        <input type="text" name="txtNumber2" id="txtNumber2" value="" class="numberinput" />
    </div>
  • 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-06-07T17:39:54+00:00Added an answer on June 7, 2026 at 5:39 pm

    Hello again 🙂 I can help you out with this as well:

    $(document).ready(function () {
        $('input.numberinput').bind('keypress', function (e) {
            var allow = (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57) && e.which != 46) ? false : true;
            if (!allow) {
                alert('Only Numerical data allowed');
            }
            return allow;
        });
    });?
    

    JSFiddle: http://jsfiddle.net/EN8pT/3/

    Enjoy and good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a homework question please help with a little explanation so that I
This question grew out of SQLServer: Why avoid Table-Valued User Defined Functions? . I
I have a question related with JPopupMenu that maybe someone can help me. As
I understand that TweetDeck can help a user to access Twitter and Facebook on
This is a followup to an earlier question ( Help Refining RegEx ("\b\d{6}([ ]{1,15})\d{7}\b")
This may be a repeat of the following unanswered question: Help with bitmap lock
I'm using the accepted answer to this question to help me build an HTML
I am quite new to programming, i have a question please help me. (
Core Question I need help coming up with a concept to achieve my goal.
may be too simple groovy question but....please help i have a list like this:

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.