Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 578 | Replies: 6
![]() |
I
function numvalues()
{
if((window.event.keyCode>57)||(window.event.keyCode<48))
{
alert("Only Digits Are Allowed");
window.event.keyCode=null;
}
}•
•
Join Date: Jul 2008
Location: Sweet India
Posts: 977
Reputation:
Rep Power: 2
Solved Threads: 90
try this:
javascript Syntax (Toggle Plain Text)
<body onKeyDown="setCmdKeyIE(event);" > javascript: function setCmdKeyIE(event) { if(event==null) event = window.event; var cmdkeycode = ""; if (event.keyCode != 13 & event.keyCode != 33 & event.keyCode != 34 & event.keyCode < 112 ) return; ... }
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
•
•
Join Date: Jul 2008
Location: Sweet India
Posts: 977
Reputation:
Rep Power: 2
Solved Threads: 90
Firefox doesn't use the global window.event but the passes an event
object to the handler. However if you use just "event" it will work as
this will be the event object within your handler.
onkeypress="return onKeyCurrencyCheck(event, 'x')"
keyCode is also know by firefox, but if you use keypress you may check
for charCode.
object to the handler. However if you use just "event" it will work as
this will be the event object within your handler.
onkeypress="return onKeyCurrencyCheck(event, 'x')"
keyCode is also know by firefox, but if you use keypress you may check
for charCode.
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
"Firefox doesn't use the global window.event but the passes an event
object to the handler. However if you use just "event" it will work as
this will be the event object within your handler."
can u elaborate this,
u mean to say mozilla doesnt require window.event,so in order to use that function we have to send event as a paramater.
iam a asp.net developer
iam using control
<asp:textbox >
when sending event as a paramter to the function,it is returning undefined for event.
object to the handler. However if you use just "event" it will work as
this will be the event object within your handler."
can u elaborate this,
u mean to say mozilla doesnt require window.event,so in order to use that function we have to send event as a paramater.
iam a asp.net developer
iam using control
<asp:textbox >
when sending event as a paramter to the function,it is returning undefined for event.
•
•
Join Date: Jul 2008
Location: Sweet India
Posts: 977
Reputation:
Rep Power: 2
Solved Threads: 90
•
•
•
•
I
function numvalues() { if((window.event.keyCode>57)||(window.event.keyCode<48)) { alert("Only Digits Are Allowed"); window.event.keyCode=null; } }
Take this:
function numvalues(e){
if(!e) e=event;e=e.keyCode||e.which;//b.b. TroyIII p.a.e
if((e>57)||(e<48)) {alert("Only Digits Are Allowed!"); return false;}
}
document.onkeypress=numvaluesYou should use
yourElement.onkeypress=numvalues instead!p.s.: I'm not sure what were you thinking with the
window.event.keyCode=null; , but I assumed you wan'ed to dissable it. ![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)





Linear Mode