[ASP.NET]按键跳转以及按Enter以不同参数提交,及其他感应事件

1.最简单的方法
<head>
  <script language=“javascript“ event=“onkeydown“ for =“document“>
  <!--
  if (event.KeyCode==13)&&event.srcElement.type!='button'&&event.srcElement.type!='submit'&&event.srcElement.type!='reset'&&event.srcElement.type!='')
  event.KeyCode=9;
  -->
  <script>
</head>

2.随心所欲地控制
<html>

<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>按键跳转测试</title>
<script language=javascript>
 function keypress()
 {
  akey = event.keyCode;
  if(akey ==13)
  {
   GotoUrl =  'Find.aspx?'+event.srcElement.name+'='+event.srcElement.value;
   window.open(GotoUrl);
  }
 }
 function keytab1(event)
 {
  akey = event.keyCode;
  if(akey ==13)
  {
   document.forms[0].USERADDR.focus();
  }
 }
 function keytab2(event)
 {
  akey = event.keyCode;
  if(akey ==13)
  {
   document.forms[0].USERPHONE.focus();
  }
 } 
 function convertToUpper(textbox)
 {
     textbox.value = textbox.value.toUpperCase();
 } 

 function checkNum(str)
 {
  return str.match(/D/)==null
 }
 
</script>
<style>
<!--
body         { font-size: 10pt; font-family: 宋体 }
div          { border-style: ridge; border-width: 1px; padding: 10px; background-color:#DAF4FE }
-->
</style>
</head>

<body  onload="Javascript:document.forms[0].USERID.focus()">
<div style="WIDTH=254px; height:134px">
<FORM method="post">
<b>查询条件</b>
<HR>
用户编码:<INPUT type="text" name="USERID" size="20" onMouseOver="this.focus()" onkeypress="keypress()" onFocus="this.select()"><font face="Webdings">N</font><br>
用户姓名:<INPUT type="text" name="USERNAME" size="20" onMouseOver="this.focus()" onkeypress="keypress()" onFocus="this.select()"><font face="Webdings">N</font><br>
用户电话:<INPUT TYPE="text" NAME="USERPHONE" onMouseOver="this.focus()" onChange="convertToUpper(this)" onkeypress="keytab1(event)" onFocus="this.select()"><br>
用户地址:<INPUT TYPE="text" NAME="USERADDR"  onMouseOver="this.focus()" onChange="convertToUpper(this)" onkeypress="keytab2(event)" onFocus="this.select()">
</FORM>
</div>
</body>

</html>


你可能感兴趣的:(asp.net)