use Javascript "Onkeypress" command to accept only "numeric"
Discuss use Javascript "Onkeypress" command to accept only "numeric" in the JavaScript Development forum on Dev Shed. use Javascript "Onkeypress" command to accept only "numeric" JavaScript Development forum discussing JavaScript and DHTML, AJAX, and issues such as coding cross-browser JavaScript.
The ASP Free website provides in-depth information on the latest developer tools available from Microsoft. Our cadre of writers, highly experienced industry experts, reveals the best ways to use established technologies as well as new and emerging technologies. Our coverage of Microsoft's development and administration technologies is among the most respected in the IT industry today.
ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month! Download and Activate to enter!
Intel® Graphics Performance Analyzers is a powerful tool suite for analyzing and optimizing your games, media, and graphics-intensive applications. Used by some of the best developers on the planet, Intel GPA lets you maximize your app’s performance.
Posts: 6
Time spent in forums: < 1 sec
Reputation Power: 0
use Javascript "Onkeypress" command to accept only "numeric"
Good day. Is there a way to filter typed inputs right upon typing the characters using Javascript? i plan on using Javascript's "Onkeypress" command to accept only "numeric, i.e., 1,2,3...", ". (dot)", and ", (comma)" command. please help.thanks in advance.
<script type="text/javascript">
<!--
var validNums = '0123456789.';
var validInt = '0123456789';
var validLetters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
function validateKeyPress(e, validSet)
{
var key;
var keychar;
Keep in mind that this won't prevent invalid characters from being pasted into the box... you'd need an onChange or something to trap that. But I think the easier thing is to just use this and then validate server-side as well. (which should be done anyways, what with form-spoofing and all)