473,480 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Re: field value AFTER numeric validation

SAM
Evertjan. a écrit :
>
Try, IE7 & FF2 tested:
Not working on my Mac :-(
(FF2, Safari2)

keys with keyCode 48 to 57 need the shiftkey in addition to get a number
from alpha keyboard
- works with Safari
- not with F2 who return a keyCode for the shift's key
(not in the allowed plage :-( )

keys from numeric keyboard aren't more allowed ... ! :-(

But I can tape : @ & $ €

And no more backspace ... tab ... enter ... :-(
<input type="text" onkeypress="return IsNumeric(event);">

<script type='text/javascript'>
function IsNumeric(e) {
var c = e.keyCode? e.keyCode : e.charCode
if (c >= 48 && c <= 57)
return true;
alert('Only Numbers, please.');
return false;
};
</script>

This will not prevent pasting alpha strings!!!!!
Only if you use menu (and not use keyboard shortcuts)

--
sm
Jun 27 '08 #1
1 1631
SAM wrote on 31 mei 2008 in comp.lang.javascript:
Evertjan. a écrit :
>>
Try, IE7 & FF2 tested:

Not working on my Mac :-(
(FF2, Safari2)

keys with keyCode 48 to 57 need the shiftkey in addition to get a
number
from alpha keyboard
- works with Safari
- not with F2 who return a keyCode for the shift's key
(not in the allowed plage :-( )

keys from numeric keyboard aren't more allowed ... ! :-(

But I can tape : @ & $ €

And no more backspace ... tab ... enter ... :-(
><input type="text" onkeypress="return IsNumeric(event);">

<script type='text/javascript'>
function IsNumeric(e) {
var c = e.keyCode? e.keyCode : e.charCode
if (c >= 48 && c <= 57)
return true;
alert('Only Numbers, please.');
return false;
};
</script>

This will not prevent pasting alpha strings!!!!!

Only if you use menu (and not use keyboard shortcuts)
It is a bad idea anyway, as it interferes with typing habits.

Better test the string onsubmit.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 27 '08 #2

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

Similar topics

8
20300
by: Vladimir | last post by:
Hello, I have a table in MS Access database. It has one field (with BYTE datatype) that has several properties set in Lookup tab of table Design View. Display Control = Combo Box. Row Source...
1
2951
by: Brains | last post by:
hello, I am new to access .I am trying to validate a numeric field (Employee number)This field is not auto generated,it is user input field.The data entered in this field should not be less than...
2
10402
by: Doslil | last post by:
I am trying to validate the fields in my database.I have already validated the fields to check for not null.Here is what I have written for Numeric and text field. Private Function EENUM() On...
1
3365
by: S. van Beek | last post by:
Dear reader, How can I filter a numeric field with Like as criteria in a query. To filter a numeric field with <10 as criteria this will com back with the result of those records for which...
6
21307
by: Paul | last post by:
I am trying to setup a field validator and tried using the control to validate set to a dropdown list box but did not seem to work. Is there anyway to set this up or do you need to use client side...
7
12917
by: Tizzah | last post by:
What is wrong with that? regex = /^(http|https):\/\/+({1}+)*\.{2,5}(({1,5})?\/.*)?$/ if(field.hpage.value != regex.test(field.hpage.value)){ alert("Bad Homepage") field.hpage.focus()...
4
21498
by: Thiyagusathya | last post by:
Hi., Please help me for java script validation for text and numeric field.
1
2277
by: Sudarhan | last post by:
Hello frnds I have created a webbased form using asp and javascript .. while submitting the form i am validating the fields in the form .it validates the field and returns alert message. but when...
3
234
by: sylver | last post by:
To convert "12q" to "12": var text = "12q"; var twelve = parseInt(text); //twelve == 12 or you can user parseFloat()..depends on your needs :D
0
7046
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
6908
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
7048
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
7088
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
5342
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,...
1
4783
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...
0
2997
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.