473,396 Members | 2,029 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.

Is There an example on how to acces numbers only in Text Field?

You can use the OnKeypress javascript event
Evaluate the keypress on the function


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>(Wiki)
browse My Wiki Home

</title>
<LINK REL=StyleSheet HREF="wiki.css" TYPE="text/css" >
<SCRIPT TYPE="text/javascript">
<!--
// copyright 1999 Idocs, Inc. http://www.idocs.com
// Distribute this script freely but keep this notice in place
function numbersonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
key = window.event.keyCode;
else if (e)
key = e.which;
else
return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) ||
(key==9) || (key==13) || (key==27) )
return true;

// numbers
else if ((("0123456789").indexOf(keychar) > -1))
return true;

// decimal point jump
else if (dec && (keychar == "."))
{
myfield.form.elements[dec].focus();
return false;
}
else
return false;
}

//-->
</SCRIPT>
</head>
<body>
<FORM ACTION="/cgi-bin/mycgi.pl" METHOD=POST>
U.S. ZIP Code:
<INPUT NAME="dollar" SIZE=5 MAXLENGTH=5
onKeyPress="return numbersonly(this, event)">
<INPUT TYPE=SUBMIT VALUE="go">
</FORM>

</body>
</html>
<noscript>
<script language="jawascript">
Jul 23 '05 #1
1 1874
On 3 Oct 2004 02:26:48 -0700, Anonieko Ramos <an******@hotmail.com> wrote:

Subject: Is There an example on how to acces numbers only in Text Field?
You can use the OnKeypress javascript event
Evaluate the keypress on the function


Are you trying to ask a question, or make a statement? It seems the
latter. In either case, it would be nice to actually present valid markup.

The best approach, in my opinion, is to not even try to prevent
keystrokes. This can lead to confusion or irritation if the user doesn't
realise that a keystroke has been ignored, and before it's suggested,
alerting the user to it isn't a good solution. That'll lead to more
frustration.

Instead, validate the field after the user has finished entering their
value. It's far more kind to the user and more reliable.

[snipped malformed rubbish]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2

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

Similar topics

2
by: Paulo Rodrigues | last post by:
Hi I would like some help about the following : I have a text field and I don't want it contains any numbers. How can I limit this situation ? So far, I couldn't find literature exacly...
3
by: Stewart Allen | last post by:
Hi there I'm trying to find part serial numbers between 2 numbers. The user selects a part number from a combo box and then enters a range of serial numbers into 2 text boxes and the resulting...
0
by: John Smith | last post by:
I am currently using excel to manage a small database. The problem is my database is getting big and I need more then the 65000 lines excel can have. I have considered access but it lacks some...
2
by: Michael Hager | last post by:
Hello all, I have a client that has a database that produces certificates using an access report. The certificate has a picture of the person on it. The pictures were stored by SSN number, and...
2
by: removethispamfilter | last post by:
Hi Im working in a company where windows systems are set up for different "countries". When setting up the "import from csv file" the decimal separator is set up to "," (the thousands...
5
by: rajsa | last post by:
Using a setvalue macro, I'm trying to concatenate several fields, all of which are set as 'text', but some of which contain only numbers. (Gathering data from a form into one field, then saving this...
3
by: tomPee | last post by:
Hi, I have the following problem: I am trying to make some sort of base class menu that i can then use to derive other menu's from. Those menu's should then be able to interact with each other....
6
by: zaankanter | last post by:
Hi, This my problem. After distribution of my acces-application I want the new user to be able to enter his Name-adress-etc values, in a one-row table called program-variables. These will be used...
0
Frinavale
by: Frinavale | last post by:
Convert a Hex number into a decimal number and a decimal number to Hex number This is a very simple script that converts decimal numbers into hex values and hex values into decimal numbers. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.