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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:31:36+00:00 2026-05-15T14:31:36+00:00

I want to add <em> tag after textbox, if user inserted non-numeric format. $(‘.numeric’).keypress(function

  • 0

I want to add <em> tag after textbox, if user inserted non-numeric format.

$('.numeric').keypress(function (e) {
 var key_code = e.which;
 if (key_code != 8 && key_code != 0 && (key_code < 48 || key_code > 57)) {
    $(this).after("<em>type only numeric formatted text<em>");
    return false ;
 }
 else {
    $('em').remove();
 }
});

Textboxes more than one. HTML code:

<div>
    <label for="Area">Full Area:</label>
    <input type="text" value="" name="FullArea" id="FullArea" class="numeric">
</div>

In my jQuery code have some issues:

  1. Will add <em> more than one time, after non-numeric format;

  2. Will remove all <em> tag, if user typed numeric format (near other textboxes too, all em in page)

Need smart way to do this functionality, without issues [1] and [2].
Thanks.

  • 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-15T14:31:37+00:00Added an answer on May 15, 2026 at 2:31 pm

    I would suggest to just hide and show that,… it’s much cheaper than removing and adding again…

    try this demo

    var em = $("<em>type only numeric formatted text<em>").hide();
    $('.numeric').keypress(function (e) {
        var key_code = e.which;
        if (key_code != 8 && key_code != 0 && (key_code < 48 || key_code > 57)) {
           $(this).next("em").show();
           return false ;
        }
        else {
           $(this).next("em").hide();
        }
    }).after(em);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 497k
  • Answers 497k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try This: // vipcardclass.m #import "vipcardclass.h" @implementation vipcardclass + (UIView*)… May 16, 2026 at 11:58 am
  • Editorial Team
    Editorial Team added an answer Try: jQuery("#availability option:selected").val(); Or to get the text of the… May 16, 2026 at 11:58 am
  • Editorial Team
    Editorial Team added an answer Sort on the following expressions: =Cint(IIf(InStr(Fields!shelfnumber.Value,"-")<=1,"0",Left((Fields!shelfnumber.Value & "-"), InStr((Fields!shelfnumber.Value &… May 16, 2026 at 11:58 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

i want to add a SWF metadata tag to an ActionScript Project in Flash
I want to add at the top of my xml file some notes for
I'm trying to dynamically add results to this display and I simply want to
I have an application written in grails. I want to add a new domain
Is there a tool to automatically add the @since tag to all elements when
i am trying to call a function that is defined in a class RFIDeas_Wrapper
So I am trying to add an icon to an image, once someone has
If I do this var domElement = $(#id); and the returned element is a
I want to create a structure like: <root> <items> <myns:a s=a/> <b s=a/> </items>
I am using virtual attributes to save tags in an Entry model from a

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.