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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:59:49+00:00 2026-06-12T15:59:49+00:00

In my project i have text field that only take numeric value.but when I

  • 0

In my project i have text field that only take numeric value.but when I copy an alphabets using ctl+c and paste using ctl+v it will allow the alphabets in the text field.So I disable the the copy and paste using the following code.

$('input').bind('copy paste', function(e) {
 e.preventDefault();
});

But I want to prevent only alphabets.That means I want copy paste numeric value not alphabets.

  • 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-12T15:59:50+00:00Added an answer on June 12, 2026 at 3:59 pm

    Try this function. This may not be what you are looking for but you can do something out of this. I have done this earlier and posted on my blog.

    JS:

     $(function(){  
                    $(".numericOnly").bind('keypress',function(e){  
                              if(e.keyCode == '9' || e.keyCode == '16'){  
                                    return;  
                               }  
                               var code;  
                               if (e.keyCode) code = e.keyCode;  
                               else if (e.which) code = e.which;   
                               if(e.which == 46)  
                                    return false;  
                               if (code == 8 || code == 46)  
                                    return true;  
                               if (code < 48 || code > 57)  
                                    return false;  
                         }  
                    );  
                    $(".numericOnly").bind("paste",function(e) {  
                         e.preventDefault();  
                    });  
                    $(".numericOnly").bind('mouseenter',function(e){  
                          var val = $(this).val();  
                          if (val!='0'){  
                               val=val.replace(/[^0-9]+/g, "")  
                               $(this).val(val);  
                          }  
                    });  
               });  
    

    HTML:

     <body>  
           <input type="text" id="textBox" class="numericOnly" />  
     </body>  
    

    This will allow you to enter only numeric values only. You can’t even copy paste and drag drop.

    DEMO

    Code Link

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

Sidebar

Related Questions

I have a project that is displaying 16px text font at 0.5ems links on
i have a java ee project which has a text file that uses a
I have a joomla project. In this the text editor is tiny mace. But
I have started a project that was initially completed following Appcoda's tutorial about using
I have a project that merges in one form field two variables. Number of
I have some text fields on my project. I want that input types of
In my Rails project I have the following code: auto_link( h( wrap_long_string(post.text,50) )).gsub(/\n/,<br />)
I am currently working on android project where I want to have a text
I am working with a matlab project. And I have a text file like
I have the following text: started: Project: ProjectA, Configuration: Release Any CPU ------ I

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.