Solved

Restricting Input in HTML Textboxes to Numeric Values

Posted on 2014-12-04
2
83 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
ID: 40482582
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
ID: 40482814
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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

821 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