function check(form)
{
if (!form.name.value.length)
{
alert('请输入用户名!');
return false;
}
return true;
}
<form action="XXXXX" method="post" onSubmit="return check(this)">
..................
</form>
就是这个样子的
{
if (!form.name.value.length)
{
alert('请输入用户名!');
return false;
}
return true;
}
<form action="XXXXX" method="post" onSubmit="return check(this)">
..................
</form>
就是这个样子的
<script>
function check(form)
{
if (!form.name.value.length)
{
alert('请输入用户名!');
return false;
}
return true;
}
</script>
<form action="XXXXX" method="post" onSubmit="return check(this)">
<input type="text" id="name">
<input type="submit" value="提交">
</form>
这个判断太不严谨了
而且是错误的
为何这样if (!form.name.value.length)的语句是错误的?错误在哪里呢?
return false;
}
<form action="XXXXX" method="post">
<input type="text" id="name">
<input type="submit" value="提交" onclick="return check(this)">
</form>