本帖最后由 IndexRegisterLogin 于 2010-05-18 11:06:41 编辑

解决方案 »

  1.   

    return CheckForm();后面加个分号也不行,楼下的别说加分号 了
      

  2.   

    function CheckForm() {
      if (document.getElenmentById(txtWebUrl).Value.Length < 12) {
        alert("请输入正确的网站域名!");
        document.getElenmentById(txtWebUrl).focus();
        return false;
      }
      
    }
      

  3.   

    <form id="form1" name="form1" runat="server">
    我觉得是不是form的id和name名称不能是一样的
      

  4.   

    大小写
    Value -> value
      

  5.   

    document.form1.txtWebUrl.value.length   大小写
      

  6.   

    document.form1.txtWebUrl.value.length < 12 改成小写的也不行,有没有知道的啊
      

  7.   

    我测试了下,
    <script type="text/javascript">
            function CheckForm() {
                if (document.form1.txtWebUrl.value.length < 12) {
                    alert("请输入正确的网站域名!");
                    document.form1.txtWebUrl.focus();
                    return false;
                }
                alert("验证通过!");
            }
        </script>可“验证通过”也没有提示,所以应该不是js里面的问题,估计是调用的问题,我调用的代码前面给出了,大家帮忙看看
      

  8.   

    1.id name 别让他一样
    2.value 小写
    3.好像是在方法的每条路都要返回才行
    <script type="text/javascript">
            function CheckForm() {
                if (document.form1.txtWebUrl.value.length < 12) {
                    alert("请输入正确的网站域名!");
                    document.form1.txtWebUrl.focus();
                    return false;
                }
                alert("验证通过!");
                return true;
            }
        </script>
      

  9.   

      function CheckForm() {
                if (document.getElementById('txtWebUrl').value.length < 12) {
                    alert("请输入正确的网站域名!");
                    document.getElementById('txtWebUrl').focus();
                    return false;
                }
                alert("验证通过!");
            }
      

  10.   

    <script type="text/javascript">
    function CheckForm() {
    var txtWebUrl=<%=txtWebUrl.clientId%>;
      if (txtWebUrl.value.length < 12) {
        alert("请输入正确的网站域名!");
        txtWebUrl.focus();
        return false;
      }
      
    }
    </script>
      

  11.   


    用了母板 就得将document.getElementById('txtWebUrl')改为document.getElementById("<%=txtWebUrl.ClientID%>")
      

  12.   

    <script type="text/javascript">
            function CheckForm() {
                if (document.form1.txtWebUrl.value.length < 12) {
                    alert("请输入正确的网站域名!");
                    document.form1.txtWebUrl.focus();
                    return false;
                }
                else
               {
                   alert("验证通过!");
                   return true;
               }
            }
        </script>
      

  13.   

    <asp:Button CssClass="buttoncss" ID="btnSubmit" runat="server" Text="提交" OnClientClick="return CheckForm();" OnClick="btnSubmit_Click" />
    能够验证了,上面的问题解决了,可再请教个问题,就是提示“不能为空了”,可紧接着就提示“系统信息修改完成”,为什么会执行btnSubmit_Click呢???
    protected void btnSubmit_Click(object sender, EventArgs e)
        {
            WKM_WebConfig configInfo = WKM_WebConfigManager.GetWKM_WebConfigInfo();
            configInfo.Web_Url = this.txtWebUrl.Text;
            
            WKM_WebConfigManager.ModifyWKM_WebConfig(configInfo);
            Response.Write("<script>alert('系统信息修改完成');location.href='WebConfig.aspx';</script>");
        }
      

  14.   

    在验证完非空后,我已经返回false了,为什么还执行btnSubmit_Click呢?