on
英[ɒn] 美[ɑ:n]
prep. (indicating direction) to; (indicating object) to; (indicating position) on...; (indicating time) at the time of...
adv. (put, wear, connect) on; forward, (continue) go on
adj. active situation, state ;used; happening; planned
key
英[ki:] 美[ki]
n.Key; Key (of a typewriter, etc.); key, clue, secret; key (of music)
vt. Type; lock; adjust the tone of...; provide clues
vi. Use a key
adj.Key; main
Third person singular: keys Plural: keys Present participle: keying Past tense: keyed Past participle: keyed
press
英[pres] 美[prɛs]
vt. Press, press; force; hug tightly
vi. Press; force; press hard
n. Press; forced conscription; news reports, publications; printing press (factory)
Third person singular: presses Plural: presses Present participle: pressing Past tense: pressed Past participle: pressed
javascript onkeypress attribute syntax
Function: Occurs when a keyboard key is pressed and a key is released.
Syntax: onkeypress="SomeJavaScriptCode"
Parameters: SomeJavaScriptCode Required. Specifies the JavaScript to be executed when this event occurs.
javascript onkeypress attribute example
<html>
<body>
<script type="text/javascript">
function noNumbers(e)
{
var keynum
var keychar
var numcheck
if(window.event) // IE
{
keynum = e.keyCode
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which
}
keychar = String.fromCharCode(keynum)
numcheck = /\d/
return !numcheck.test(keychar)
}
</script>
<form>
用户无法输入数字:
<input type="text" onkeypress="return noNumbers(event)" />
</form>
</html>Run instance »
Click the "Run instance" button to view the online instance
