asp.net2.0里javascript验证提交的问题
帮忙看看以下这段代码,每次提交的时候,本来是想检验登录名没有输入的时候,就弹出提示.
但结果可以弹出提示,但效果是仍然会post到服务器端,然后刷新页面?
这里我已经用了return false,为什么还会提交呢?
<script type= "text/javascript " language= "javascript ">
function verifyForm()
{
var frm = document.forms[0];
if(frm.txtLogid.value == " ")
{
alert( "登录名不能为空 ");
frm.txtLogid.style.backgroundColor= "#ff6600 ";
frm.txtLogid.focus();
return false;
}
}
</script>
<form id= "regForm " method= "post " runat= "server ">
<asp:TextBox ID= "txtLogid " Width= "100px " CssClass= "textbox " runat= "server "> </asp:TextBox> *
<asp:Button ID= "btnAdd " runat= "server " Text= "提交 " CausesValidation= "False " OnClick= "btnAdd_Click " OnClientClick= "return verifyForm() " />
</form>
[解决办法]
你把method= "post "去掉呢?