can only input English and digital <input onkeyup= "Value=value.replace (/[\w]/g,") "Onbeforepaste=" Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^\d]/g, ') ">
Can only be digital <input onkeyup= "Value=value.replace (/[^\d]/g,") "Onbeforepaste=" Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^\d]/g, ') ">
Can only display, cannot modify <input readonly value= "Only show, cannot modify" >
Can only be a number to determine the value of the key.
<script language=javascript>
function Onlynum ()
{
if (!) ( (event.keycode> =48&&event.keycode<=57) | | (event.keycode> =96&&event.keycode<=105) | | (event.keycode==8)))
Event.returnvalue=false;
}
</script>
<input >
Attach: Get the keycode of keyboard
<script language= "JavaScript" >
NS4 = (document.layers)? True:false;
ie4 = (document.all)? True:false;
function KeyDown (e) {
if (NS4) {
var Nkey=e.which;
var iekey= ' is now NS browser ';
var realkey=string.fromcharcode (E.which);
}
if (IE4) {
var Iekey=event.keycode;
var nkey= ' is now IE browser ';
var realkey=string.fromcharcode (Event.keycode);
if (event.keycode==32) {realkey= ' \ ' Space \ '}
if (event.keycode==13) {realkey= ' \ ' carriage return \ '}
if (event.keycode==27) {realkey= ' \ esc\ '}
if (event.keycode==16) {realkey= ' \ shift\ '}
if (event.keycode==17) {realkey= ' \ ctrl\ '}
if (event.keycode==18) {realkey= ' \ alt\ '}
}
Alert (in ' NS browser key value: ' +nkey+ ' \ n ' + ' + ' IE browser key value: ' +iekey+ ' \ n ' + ' actual key is ' +realkey ');
}
Document.onkeydown = KeyDown;
if (NS4) {
Document.captureevents (Event.keydown);}
</script>
<body>
Javascript Document.
<center>
</center>
</body>
restricting keyboard for Web pages
<body >
Limit a key on the keyboard: The body ASCII code is: "+event.keycode";
}
</script>
<body >
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.