<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>
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>
这句里面的括号位置弄错了……
改成下面这样:
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>