
请分析下为什么这段js代码不执行?
<scriptlanguage="javaScript">functioncheck(){varusername=document.form1.name.value;va...
<script language="javaScript">
function check()
{
var username = document.form1.name.value;
var shortname = document.form1.shortname.value;
var sex=document.form1.sex.value;
var pwd = document.form1.pwd.value;
var pwd2 = document.form1.pwd2.value;
var tel=document.form1.tel.value;
var idno=document.form1.idno.value;
var addr=document.form1.addr.value;
if (username==""|| pwd==""||pwd2==""||tel==""||idno==""||shortname==""||addr=="")
{
alert("任意信息不能为空,请重新填写!");
return false;
}
else if(username.length>20){
alert("用户名不能超过20个字符,请重新输入!");
return false;
}
else if(pwd.length<4){
alert("密码不能小于6个字符,请重新输入!");
return false;
}
else if(tel.length > 20)
{
alert("联系方式长度不能超过20字符!");
return false;
}
else if (isNaN(tel))
{
alert("联系方式必须是数字");
return false;
}
else if (addr.length>40)
{
alert("收货地址不能超过40字符!");
return false;
}
else if (pwd!=pwd2)
{
alert("2次密码输入不一致!");
return false;
}
else{
return true;
}
}
</script>
form表单是这样的:<form id=form1 name="form1" method="post" action="re_act.asp" onsubmit="return check()">...</form> 展开
function check()
{
var username = document.form1.name.value;
var shortname = document.form1.shortname.value;
var sex=document.form1.sex.value;
var pwd = document.form1.pwd.value;
var pwd2 = document.form1.pwd2.value;
var tel=document.form1.tel.value;
var idno=document.form1.idno.value;
var addr=document.form1.addr.value;
if (username==""|| pwd==""||pwd2==""||tel==""||idno==""||shortname==""||addr=="")
{
alert("任意信息不能为空,请重新填写!");
return false;
}
else if(username.length>20){
alert("用户名不能超过20个字符,请重新输入!");
return false;
}
else if(pwd.length<4){
alert("密码不能小于6个字符,请重新输入!");
return false;
}
else if(tel.length > 20)
{
alert("联系方式长度不能超过20字符!");
return false;
}
else if (isNaN(tel))
{
alert("联系方式必须是数字");
return false;
}
else if (addr.length>40)
{
alert("收货地址不能超过40字符!");
return false;
}
else if (pwd!=pwd2)
{
alert("2次密码输入不一致!");
return false;
}
else{
return true;
}
}
</script>
form表单是这样的:<form id=form1 name="form1" method="post" action="re_act.asp" onsubmit="return check()">...</form> 展开
3个回答
展开全部
嘛,没有仔细看,如果代码没有问题,名字没有写错,应该是js没有加载,异步回调的问题。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询