•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 427,177 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,244 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 498 | 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: 828
Reputation:
Rep Power: 2
Solved Threads: 74
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: 828
Reputation:
Rep Power: 2
Solved Threads: 74
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: 828
Reputation:
Rep Power: 2
Solved Threads: 74
•
•
•
•
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. ![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- HTML, CSS, JavaScript Developer (Web Development Job Offers)
- Are you a PHP and Javascript junkie? It's time you met Emma. (Software Development Job Offers)
- JavaScript's window.opener (JavaScript / DHTML / AJAX)
- recommendations for JavaScript learning resources? (JavaScript / DHTML / AJAX)
- Javascript/HTML problem!!! (JavaScript / DHTML / AJAX)
- Javascript Useful? (IT Careers and Business)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Need help in sudoku coding 4 by 4 dimentional.
- Next Thread: how does Scribblelive work?


Linear Mode