Solved

Restricting Input in HTML Textboxes to Numeric Values

Posted on 2014-12-04
2
80 Views
Last Modified: 2014-12-11
Restricting Input in HTML Textboxes to Numeric Values
0
Comment
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
Comment Utility
Test page : http://jsfiddle.net/uz1xweoh/

$("#THISISMYID").on("keyup blur focus paste", function() { 
      $(this).val( $(this).val().replace(/\D/g,"") );
});

Open in new window

0
 
LVL 10

Expert Comment

by:Hans Langer
Comment Utility
If you are using jquery would recommend you this plugin. its works to validate the most common formats, money, date, etc..
http://digitalbush.com/projects/masked-input-plugin
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now