可以的,你可能什么地方写错了,试试下面这个,对比着看一下:
<html><body>
<script>
function check(){
if(form1.text1.value.length==0){
alert("不能为空");
return false;
}
}
</script>
<form name="form1" method="post" onsubmit="return check()">
<input type="text" name="text1">
<input type="submit">
</form>
</body></html>
<html><body>
<script>
function check(){
if(form1.text1.value.length==0){
alert("不能为空");
return false;
}
}
</script>
<form name="form1" method="post" onsubmit="return check()">
<input type="text" name="text1">
<input type="submit">
</form>
</body></html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货