javascript表单未通过验证 form仍然跳转
js:<scriptlanguage=javascript>functionCheckForm(){if(document.UserLogin.uname.value==...
js:<script language=javascript>
function CheckForm()
{
if(document.UserLogin.uname.value=="")
{
alert("请输入用户名!");
document.UserLogin.UserName.focus();
history.back()
return false;
}
if(document.UserLogin.pass.value == "")
{
alert("请输入密码!");
document.UserLogin.pass.focus();
return false;
}
}
</script>
form: <form action="a" method="post" name="UserLogin" onsubmit="return CheckForm();"> 展开
function CheckForm()
{
if(document.UserLogin.uname.value=="")
{
alert("请输入用户名!");
document.UserLogin.UserName.focus();
history.back()
return false;
}
if(document.UserLogin.pass.value == "")
{
alert("请输入密码!");
document.UserLogin.pass.focus();
return false;
}
}
</script>
form: <form action="a" method="post" name="UserLogin" onsubmit="return CheckForm();"> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询