Cheers Massimo. I will take a look.
Just as an answer to my problem, it's probably down to changing the field
with script which is causing the change not to be picked up. So to get
around it, I only change the text if a char is not allowed.
So from this:
function keyUpped(obj) {
obj.value = obj.value.replace(/[^0-9]/g, "");
document.getElementById("output").innerHTML += "<p>KEY UP</p>";
}
to this:
function keyUpped(obj) {
if ( obj.value.search(/[^0-9]/g, "") == 1 ) {
obj.value = obj.value.replace(/[^0-9]/g, "");
}
document.getElementById("output").innerHTML += "<p>KEY UP</p>";
}
The first one changes the text regardless, the second one first checks if it
needs changing before doing so.
Adrian
-----Original Message-----
From: Massimo Foti [mailto:[EMAIL PROTECTED]
Sent: 28 February 2006 19:57
To: CF-Talk
Subject: Re: OT JS onChange/onKeyUp Event Issue
> I have a text field, in this I only want the user to type numbers, so
> onkeyup runs a RegEx to remove a char if it's not a number.
You may want to take a lookat this:
http://www.massimocorner.com/validator/samples/filters.htm
It's part of a larger library:
http://www.massimocorner.com/validator/
----------------------------
Massimo Foti
Tools for ColdFusion and Dreamweaver developers:
http://www.massimocorner.com
----------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:233670
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54