如:
 <input type="text" onkeypress="AsciiUp(this,event);" />
<script>
function AsciiUp(send,event)
{
  ????
}
</script>谢谢

解决方案 »

  1.   

    使用onkeydown
    onkeypress时input的value已经改变了
      

  2.   

    <input type="text" onkeypress="return AsciiUp(this,event);" />
    <script>
    function AsciiUp(obj,e){
     var ev = window.event || e; 
     var cd = ev.keyCode || ev.charCode;
     if(cd >=65 && cd <90 || cd  >=97 && cd < 122) {
    ev.keyCode && (ev.keyCode = ev.keyCode+1);
    if(ev.charCode){
    obj.value=obj.value+String.fromCharCode(ev.charCode+1) ;
    return false;
    }
     }
    }
      

  3.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>测试</title><script type="text/javascript">
    <!--
    function AsciiUp(event){
    var e = event || window.event;
    var code = e.keyCode || e.which;
    if((64 < code && code <90) || (96 < code && code < 122)){
    code ++;
    var target = e.target || e.srcElement;
    target.value += String.fromCharCode(code);
    return false;
    }
    }
    //-->
    </script>
    </head><body>
    <input type="text" onkeypress="return AsciiUp(event)" />
    </body>
    </html>
      

  4.   


    这里用onkeydown的话获取的keyCode会不准确(不能区分大小写)
      

  5.   

    ------------------
    这样不行,因为这样t
    arget.value += String.fromCharCode(code);
    只是给target.value添加上当前输入的值+1
    再在后面的return false,停止掉onkeeypress
    但,我可以不是在最后输入,而是在前面或中间输入,所以这样的代码不是很好
      

  6.   

    #4
    keyCode不能区分大小写,第一次听说