Enter后光标移到下一个输入框---网页制作中表单相关特效

来源:互联网 发布:网络主播幽默的台词 编辑:程序博客网 时间:2024/05/03 04:23
<!--只能是一些限定的东西--><!--ENTER键可以让光标移到下一个输入框;值13表示Enter;9表示Tab--><input onkeydown="if(event.keyCode==13)event.keyCode=9" > <br><!--只能是中文--><input onkeyup="value=value.replace(/[ -~]/g,'')" onkeydown="if(event.keyCode==13)event.keyCode=9"> <br><!--屏蔽输入法--><input style="ime-mode:disabled" onkeydown="if(event.keyCode==13)event.keyCode=9"> <br><!--只能输入英文和数字--><input onkeyup="value=value.replace(/[\W]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" onkeydown="if(event.keyCode==13)event.keyCode=9"> <br><!--只能是数字--><input onkeyup="value=value.replace(/[^\d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"><br><!--只能显示,不能修改--><input readonly value="只能显示,不能修改"><!--只能是数字,判断按键的值--><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  onkeydown="onlyNum();"> <!--附:获取键盘的KeyCode--><html><head><script language="javascript">  ns4 = (document.layers) ? true : false;  ie4 = (document.all) ? true : false;function keyDown(e){  if(ns4){  var nkey=e.which;  var iekey='现在是ns浏览器';  var realkey=String.fromCharCode(e.which);}  if(ie4){  var iekey=event.keyCode;  var nkey='现在是ie浏览器';  var realkey=String.fromCharCode(event.keyCode);  if(event.keyCode==32){realkey='\' 空格\''}  if(event.keyCode==13){realkey='\' 回车\''}  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('ns浏览器中键值:'+nkey+'\n'+'ie浏览器中键值:'+iekey+'\n'+'实际键为'+realkey);}document.onkeydown = keyDown;if(ns4){document.captureEvents(Event.KEYDOWN);}</script></head><body>//Javascript Document.<hr><center><h3>请按任意一个键。。。。</h3></center></body></html><!--限制网页用键盘--><body onkeydown="alert('禁用');return false;"><!--限制键盘的某个键:-->body onkeydown="if(event.keyCode==num){alert('禁用');return false;}<!--再加个找按键的值--><script>function show(){  alert("ASCII代码是:"+event.keyCode);}</script><body onkeydown="show()"><!--只能是IP地址--><html><head><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地址错误!")           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地址输入</title></head><body>IP地址输入   <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></html><!--用#default#savehistory防止后退清空text文本框:--><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='点击进入,再按后退键试试?'></BODY></HTML><!--TEXTAREA自适应文字行数的多少--><textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight"><!--上传预览图片--><img id=pic  src=http://webdesign.chinaitlab.com/UploadFiles_8014/200604/20060418102923102.gif><input type=file name=file><input type=button onclick=pic.src=file.value value=预览图片><input type=button onclick=alert(file.value) value=图片地址><input type=button onclick="file.outerHTML=file.outerHTML.replace(/value=\w/g,'')" value="清除file里字">

0 0
原创粉丝点击