<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>无标题页</title>
    <script type="text/javascript">
        function txtCheck(a){
            var regex=/.+@.+/;
            if(regex.test(a.value)){
                a.style.borderColor="black";
                document.getElementById("Submit1").style.enable=true;
            }
            else {
                a.style.borderColor="red";
                document.getElementById("Submit1").style.enable=false;
            }
        }
    </script>
</head>
<body>
<form action="ok.aspx">
    <input id="Text1" type="text" onblur="txtCheck(this)" />
    <input id="Submit1" type="submit" value="submit" />
</form>
</body>
</html>

解决方案 »

  1.   

    var regex=/.+@.+/;失去焦点时 验证TEXT1中用户输入信息 是否含有 @ ,邮箱格式
    如果符合格式 则允许SUBMIT
    否则不允许SUBMIT 且红色提示
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <title>????</title>
      <script type="text/javascript">
      function txtCheck(a){
      var regex=/.+@.+/;
      if(regex.test(a.value)){
      a.style.borderColor="black";
      document.getElementById("Submit1").disabled = false;
      }
      else {
          a.style.borderColor = "red";
      document.getElementById("Submit1").disabled =true;
      }
      }
      </script>
    </head>
    <body>
    <form action="ok.aspx">
      <input id="Text1" type="text" onblur="txtCheck(this)" />
      <input id="Submit1" type="submit" value="submit" />
    </form>
    </body>
    </html>
      

  3.   

    哥们,还是不行,那个失去焦点时submit还是没有被禁用
      

  4.   


    document.getElementById("Submit1").disabled =true;=====>document.getElementById("Submit1").disabled  = "disabled";
      

  5.   

    我随便输入了一个字符,然后焦点离开文本框submit按钮没有禁用
      

  6.   

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>无标题页</title>    <script type="text/javascript">
      function txtCheck(a){
          var regex=/.+@.+/;
          if(regex.test(a.value)){
                a.style.borderColor="black";
                document.getElementById("Submit1").disabled  = "";
          }
          else {
            a.style.borderColor="red";
            
             document.getElementById("Submit1").disabled  = "disabled";
          }
      }
        </script></head>
    <body>
        <form id="form1" runat="server">
        <div>
         <input id="Text1" type="text" onblur="txtCheck(this)" />
      <input id="Submit1" name="Submit1" type="submit" value="submit" />
        </div>
        </form>
    </body>
    </html>