asp 表单提交验证js不起作用,望各位指点!!!
asp 有一个表单提交页面,但js不起作用,空信息也能提交成功,不知是何原因,现在我把代码贴出来,望指教……
<form action="baoxian-book.asp" method=post name=editform onSubmit="return checkinput(editform)">
…………………………
…………………………………………
</form>
js
<script language="Javascript">
function checkinput(form)
{
var flag=true;
if (form("name").value == "")
{
alert("申请人姓名不能为空!"); form("name").focus(); flag = false; return flag
}
else
{
flag=true
}
if (form("enname").value == "")
{
alert("参团人英文名字不能为空!"); form("enname").focus(); flag = false; return flag
}
else
{
flag=true
}
if (form("passport").value == "")
{
alert("护照号码不能为空!"); form("passport").focus(); flag = false; return flag
}
else
{
flag=true
}
if (form("email").value == "")
{
alert("email不能为空!"); form("email").focus(); flag = false; return flag
}
else
{
flag=true
}
if (form("company").value == "")
{
alert("发票名字不能为空!"); form("company").focus(); flag = false; return flag
}
else
{
flag=true
}
if (form("destination").value == "")
{
alert("出访国家不能为空!"); form("destination").focus(); flag = false; return flag
}
else
{
flag=true
}
if (form("phone").value == "")
{
alert("电话不能为空!"); form("phone").focus(); flag = false; return flag
}
else
{
flag=true
}
if (form("address").value == "")
{
alert("通讯地址不能为空!"); form("address").focus(); flag = false; return flag
}
return flag;
}
</script>
------解决方案--------------------form.name
这样写法也不多。name是保留字。
------解决方案--------------------HTML code
<form action="baoxian-book.asp" method="post" name="editform" onsubmit="return checkinput(this.form)">
------解决方案--------------------
HTML code
<form action="baoxian-book.asp" method=post name=editform onSubmit="return checkinput()">
姓名:<input type="test" name="name" />
参团人英文名:<input type="test" name="enname" />
护照号码:<input type="test" name="passport" />
email:<input type="test" n