JavaScript Web page production of form-related special effects finishing

Source: Internet
Author: User
Tags eval key modify return microsoft frontpage
javascript| Special Effects | Web pages can only be a limited number of things

Enter to move the cursor to the next input box
<input >


Can only be Chinese <input onkeyup= "value=value.replace (/[-~]/g,") ">


Shielding Input Method <input style= "ime-mode:disabled" >


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 >

Can only be an IP address


<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<meta name= "generator" content= "Microsoft FrontPage 4.0" >
<meta name= "ProgId" content= "FrontPage.Editor.Document" >
<style>
. A3{width:30;border:0;text-align:center}
</style>
<script>
function Mask (obj) {
Obj.value=obj.value.replace (/[^\d]/g, "")
Key1=event.keycode
if (key1==37 | | key1==39)
{Obj.blur ();
Nextip=parseint (Obj.name.substr (2,1))
nextip=key1==37?nextip-1:nextip+1;
Nextip=nextip> =5?1:nextip
Nextip=nextip<=0?4:nextip
eval ("IP" +nextip+ ". Focus ())"
}
if (obj.value.length> =3)
if (parseint (obj.value) > =256 | | parseint (obj.value) <=0)
{
Alert (parseint (obj.value) + "IP address error! ")
Obj.value= ""
Obj.focus ()
return false;
}
Else
{Obj.blur ();
Nextip=parseint (Obj.name.substr (2,1)) +1
Nextip=nextip> =5?1:nextip
Nextip=nextip<=0?4:nextip
eval ("IP" +nextip+ ". Focus ())"
}
}
function Mask_c (obj)
{
Clipboarddata.setdata (' Text ', Clipboarddata.getdata (' text '). Replace (/[^\d]/g, ')
}

</script>
<title> IP Address Input </title>

<body> IP Address input
<div style= "Border-width:1;border-color:balck;border-style:solid;width:165;font-size:9pt" >
<input type=text name=ip1 maxlength=3 class=a3 onkeyup= "Mask (This)" Onbeforepaste=mask_c () >.
<input type=text name=ip2 maxlength=3 class=a3 onkeyup= "Mask (This)" Onbeforepaste=mask_c () >.
<input type=text name=ip3 maxlength=3 class=a3 onkeyup= "Mask (This)" Onbeforepaste=mask_c () >.
<input type=text name=ip4 maxlength=3 class=a3 onkeyup= "Mask (This)" Onbeforepaste=mask_c () >
</div>
</body>


Use #default#savehistory to prevent back-emptying the text text box:

<HTML>
<HEAD>
<meta name= "Save" content= "History" >
<STYLE>
. savehistory {Behavior:url (#default #savehistory);}
</STYLE>
</HEAD>
<BODY>
<input class=savehistory Type=text id=opersistinput>
<input Type=button onclick= ' javascript:location.href= ' http://www.webjx.com/' value= ' Click to enter, and then press the back button to try? ' >
</BODY>
</HTML>

TextArea the number of adaptive lines of text

<textarea Rows=1 name=s1 cols=27 onpropertychange= "This.style.posheight=this.scrollheight" >

Upload preview picture


<input type=file name=file> <input Type=button onclick=pic.src=file.value-value= Preview Pictures >
<input Type=button Onclick=alert (file.value) value= image address >
<input Type=button value= "clear file in Word" >

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.