<input onkeyup="value=value.replace(/[\W]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">2)大小写方法 
JavaScript严格区分字母的大小写。为了方便地比较两个串,就 
要把它们都转化为大写或小写。串对象的大小写方法就支持在大小写 
之间转换。 
toLowerCase() 
tolowerCase()方法把一个给定的串中每个字符转变成小写状态 
。语法形式如下: 
string=stringValue.toLowerCase(); 
toUpperCase() 
与tolowerCase()方法相反是toUpperCase()方法,它把一个给定 
串转变成大写字符串。 
string=stringValue.toUpperCase();

解决方案 »

  1.   

    <html>
    <head>
    <script language=javascript>
      function btnTest_onclick(){
        if (check1(f1.txtTest1.value))
          alert(f1.txtTest1.value.toLowerCase());
      }
      
      function check1(AJudgeString){
        for (i=0;i<AJudgeString.length;i++){
          tempCode = AJudgeString.charCodeAt(i) ;
          if (!( (tempCode>=97 && tempCode<=122) || (tempCode>=65 && tempCode<=90) || tempCode==32)){
            alert("输入非法字符!"); 
            return false;
          }
        } 
        return true;
      } 
      
      function change1(AJudgeString){
        var tmpStr="";
        var tmpChar;
        var tempCode;
        for (i=0;i<AJudgeString.length;i++){
          tempCode = AJudgeString.charCodeAt(i) ;
          if (tempCode>=97 && tempCode<=122){
            tmpStr=tmpStr+(tempCode-32).toString();
          }else{
            tmpStr=tmpStr+(tempCode).toString();
          }
        } 
      }
    </script>
    </head>
    <body>
    <form name=f1>
    <table>
      <tr>
        <td>
          <input type=text name=txtTest1 value="">
        </td>
      </tr>
      <tr>
        <td>
          <input type=text name=txtTest2 value="">
        </td>
      </tr>
      <tr>
        <td>
          <input type=button name=btnTest value="测 试" onclick="btnTest_onclick();">
        </td>
      </tr>
    </table>
    </form>
    </body>
    </html>
      

  2.   

    直接在输入框中屏蔽是做不到的,至少你的复制功能就可以跳过一般的onkeydown事件,一般而言还是在提交时判断吧!
      

  3.   

    <script>
    function test()
    {
    if((event.keyCode>64 && event.keyCode<91) || event.keyCode==32) 
    return true
    else
    event.returnValue=false
    }
    </script>
    <input name="net_lover" onkeydown="test()" onkeyup="this.value=this.value.toUpperCase()" onpaste="return false">
      

  4.   

    pokar(因为菜所以菜) ,不好意思,能否解释一下 /[\W]/g 和 /[^\d]/g ?谢谢了!
      

  5.   

    写错一句话
    toLowerCase()--》toUpperCase();
      

  6.   

    to net_lover(孟子E章) :又从老大那里学了一招