Active Server Pages

Moderators: None (Apply to moderate this forum)
Number of threads: 1739
Number of posts: 4450

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
use Javascript "Onkeypress" command to accept only "numeric". Posted by jomargon on 17 Aug 2004 at 8:02 PM
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.
Report
Re: use Javascript "Onkeypress" command to accept only "numeric". Posted by BijuRaj on 28 Jul 2005 at 2:59 AM
: 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.
:

=================================================
Here is your solution
=================================================

<Input Type="Text" Name="txtTerms" Value="" Size="20" Class="txtbk" onKeypress="if (event.keyCode < 44 || event.keyCode > 57 || event.keyCode==45 || event.keyCode==47) event.returnValue = false;">


Report
Re: use Javascript "Onkeypress" command to accept only "numeric". Posted by elizas on 10 Jun 2010 at 6:31 AM
Basicallly When we trying to validate a form some time we need numeric validation for textbox.

We can validate textbox by onkeypress event of the control By checking whether the keycode of the key pressed as the user types falls within the range of the number keys 48-57(i.e 0-9 and '.') ,if not belong to that range it will return false then it will disable the keypress action
function NumericValidation(eventObj)
{
var keycode;

if(eventObj.keyCode) //For IE
keycode = eventObj.keyCode;
else if(eventObj.Which)
keycode = eventObj.Which; // For FireFox
else
keycode = eventObj.charCode; // Other Browser

http://www.mindfiresolutions.com/Numeric-validation-using-Javascript-612.php




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.