谁帮忙看看javascript表单验证错在哪里了

来源:百度知道 编辑:UC知道 时间:2024/05/08 03:35:59
<script language="javascript">
function checkform()
{
if(document.thisform.name.value)==""{
alert("please input your name");
document.thisform.name.focus();
return false;
}
return true;
}
</script>
<form action="reg.asp" method="post" name="thisform" onsubmit="return checkform()">
<input type="text" name="name">
<input type="submit" value="ok">
</form>

if(document.thisform.name.value)==""
这句里面的括号位置弄错了……
改成下面这样:
if(document.thisform.name.value=="")
就行了
全部代码:
<script language="javascript">
function checkform()
{
if(document.thisform.name.value==""){
alert("please input your name");
document.thisform.name.focus();
return false;
}
return true;
}
</script>
<form action="reg.asp" method="post" name="thisform" onsubmit="return checkform()">
<input type="text" name="name">
<input type="submit" value="ok">
</form>