运行时弹出消息框:当前页的脚本发生错误!
那怎么解决浏览器端的验证呢?
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "Default.aspx.cs " Inherits= "_Default " %>
<!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>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<asp:TextBox ID= "TextBox1 " runat= "server "> </asp:TextBox>
<asp:CustomValidator ID= "CV1 " runat= "server " ErrorMessage= "CustomValidator " OnServerValidate= "CV1_ServerValidate "> </asp:CustomValidator>
<script type= "text/jscript ">
function usercheck
{
var regx=/\w{10}/;
var rs=regx.exec(TextBox1.Text);
if rs!=TextBox1.Text
CV1.IsValid=false
}
</script>
<asp:Button ID= "Button1 " runat= "server " Text= "Button " /> </div>
</form>
</body>
</html>
------解决方法--------------------------------------------------------
js代码不应放在 <Form runat= "server "> </Form> 内.
------解决方法--------------------------------------------------------
查看你的页面的客户端源代码,然后根据它说出哪里出错了(vs可以调试脚本,你可以分析变量、单布执行脚本等等)。