473,396 Members | 2,093 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Numeric/Decimals only...

<PUBLIC:ATTACH EVENT="onkeypress" ONEVENT="keyPress()"/>

<SCRIPT LANGUAGE="JScript">

function keyPress(){
if (!(window.event.keyCode >= 48 && window.event.keyCode <= 57) && !
(window.event.keyCode == 46)){
window.event.keyCode = 0;
}
}

</SCRIPT>

Hello... I'm new to HTC/JScript thing.
I have a textfield that uses the JScript behavior above.
(The JScript above only accepts 0-9 and .)
I want to customize my textfield such that only numbers/decimals can
be entered like:
2.45, 8.456 and 8. Not texts like "..5" or "." or "1.25..." or
"1..53." and the like.
Is that possible with JScript? Please do reply... Thanks a lot.

Mar 16 '07 #1
2 1709
On Mar 16, 6:45 pm, "IveCal" <ive....@gmail.comwrote:
<PUBLIC:ATTACH EVENT="onkeypress" ONEVENT="keyPress()"/>

<SCRIPT LANGUAGE="JScript">

function keyPress(){
if (!(window.event.keyCode >= 48 && window.event.keyCode <= 57) && !
(window.event.keyCode == 46)){
window.event.keyCode = 0;
}

}

</SCRIPT>

Hello... I'm new to HTC/JScript thing.
I have a textfield that uses the JScript behavior above.
(The JScript above only accepts 0-9 and .)
I want to customize my textfield such that only numbers/decimals can
be entered like:
2.45, 8.456 and 8. Not texts like "..5" or "." or "1.25..." or
"1..53." and the like.
Is that possible with JScript?
Yes. Forget using keycodes, use a regular expression:

<URL: http://www.merlyn.demon.co.uk/js-valid.htm#VNP >

Don't prevent any keystrokes, validate when the user has finished
using blur or change events.
--
Rob

Mar 16 '07 #2
Oh... Thanks a lot...

Mar 19 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: David Garamond | last post by:
In Interbase and Firebird, NUMERIC is implemented as 64-bit integer. This limits the range to NUMERIC(18, *) but for many uses that's adequate. And moreover it's fast and efficient. Is there a...
11
by: Pieter | last post by:
Hi, I'm having some troubles with my numeric-types in my VB.NET 2005 application, together with a SQL Server 2000. - I first used Single in my application, and Decimal in my database. But a...
11
by: Pieter | last post by:
Hi, I'm having some troubles with my numeric-types in my VB.NET 2005 application, together with a SQL Server 2000. - I first used Single in my application, and Decimal in my database. But a...
7
by: Jose | last post by:
How obtain a textbox numeric with 2 decimals and formated. Example: 234,898.90. The idea is not permit introduced twice point decimals and show it professionaly. Thanks
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.