<input name="haha" onblur="if(!/^[A-Z]$/i.test(this.value)){alert('错误');this.value=''}">

解决方案 »

  1.   

    <input name="haha" onblur="if(!/^[A-Z]*$/i.test(this.value)){alert('错误');this.value=''}">
      

  2.   

    <input name="haha" onblur="if(!/^[A-Z0-9]*$/i.test(this.value)){alert('错误');this.value=''}">
      

  3.   

    是可以做到了,但是我还有一个问题。如果我要做成js文件怎么写。
    <script >
    function check()
    {
    var reg = /^[A-Z0-9]*$/;
    if( !reg.test(document.getElementById("aaa")) )
    {
      response.write "OK"
    }
                      else
                      {
                        response.write "error"                  }
    }
    </script >这样写对吗?
    我要想调用这个JS要怎么写呢。高手帮我
      

  4.   

    response.write "OK"
    这句不对,别把ASP和JS混了,要换成
    alert("OK")
      

  5.   

    谢谢! 结贴。加我MSN吧。[email protected]
      

  6.   

    <script >
    function check()
    {
    var reg = /^[A-Z0-9]*$/;
    if( !reg.test(document.getElementById("aaa")) )
    {
    alert("OK");
    }
    else
    {
    alert("error");}
    }
    </script >
      

  7.   

    function isTextBox(o) {
    if (/[^A-Za-z\d]/.test(o.value)) alert("Err");
    else alert("Yes");
    }
    放到某JS里(注意顺序)
    调用的话。
    <input name="haha" onblur="isTextBox(this);" />